From 781b547daad1eb7d8d3e3d5eeea314bc931dfba9 Mon Sep 17 00:00:00 2001 From: Daniel Hok Date: Thu, 5 Sep 2024 18:06:29 -0400 Subject: [PATCH 1/5] Swift SDK changes --- .../swift/push_notifications/integration.md | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md index 22d63462ffa..684aed59051 100644 --- a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md +++ b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md @@ -319,15 +319,12 @@ Deep linking from a push into the app is automatically handled via our standard ## Subscribing to push notifications updates -{% tabs %} -{% tab Swift %} To access the push notification payloads processed by Braze, use the [`Braze.Notifications.subscribeToUpdates(payloadTypes:_:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/notifications-swift.class/subscribetoupdates(payloadtypes:_:)/) method. You can use the `payloadTypes` parameter to specify whether you'd like to subscribe to notifications involving push open events, push received events, or both. -{% alert important %} -Keep in mind, push received events will only trigger for foreground notifications and `content-available` background notifications. It will not trigger for notifications received while terminated or for background notifications without the `content-available` field. -{% endalert %} +{% tabs %} +{% tab Swift %} ```swift // This subscription is maintained through a Braze cancellable, which will observe for changes until the subscription is cancelled. @@ -337,17 +334,15 @@ let cancellable = AppDelegate.braze?.notifications.subscribeToUpdates(payloadTyp print("Braze processed notification with title '\(payload.title)' and body '\(payload.body)'") } ``` -{% endtab %} - -{% tab OBJECTIVE-C %} -To access the push notification payloads processed by Braze, use the [`Braze.Notifications.subscribeToUpdates(payloadTypes:_:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/notifications-swift.class/subscribetoupdates(payloadtypes:_:)/) method. - -You can use the `payloadTypes` parameter to specify whether you'd like to subscribe to notifications involving push open events, push received events, or both. {% alert important %} Keep in mind, push received events will only trigger for foreground notifications and `content-available` background notifications. It will not trigger for notifications received while terminated or for background notifications without the `content-available` field. {% endalert %} +{% endtab %} + +{% tab OBJECTIVE-C %} + ```objc NSInteger filtersValue = BRZNotificationsPayloadTypeFilter.opened.rawValue | BRZNotificationsPayloadTypeFilter.received.rawValue; BRZNotificationsPayloadTypeFilter *filters = [[BRZNotificationsPayloadTypeFilter alloc] initWithRawValue: filtersValue]; @@ -355,6 +350,11 @@ BRZCancellable *cancellable = [notifications subscribeToUpdatesWithPayloadTypes: NSLog(@"Braze processed notification with title '%@' and body '%@'", payload.title, payload.body); }]; ``` + +{% alert important %} +Keep in mind, push received events will only trigger for foreground notifications and `content-available` background notifications. It will not trigger for notifications received while terminated or for background notifications without the `content-available` field. +{% endalert %} + {% endtab %} {% endtabs %} @@ -362,6 +362,10 @@ BRZCancellable *cancellable = [notifications subscribeToUpdatesWithPayloadTypes: When using the automatic push integration, `subscribeToUpdates(_:)` is the only way to be notified of remote notifications processed by Braze. The `UIAppDelegate` and `UNUserNotificationCenterDelegate` system methods are not called when the notification is automatically processed by Braze. {% endalert %} +{% alert tip %} +If you want your push notification subscription to be triggered upon clicking on a notification while in the terminated state, you should set your subscription in `application(_:didFinishLaunchingWithOptions:)`. This will ensure that the subscription is set up prior to processing the push click. +{% endalert %} + ## Testing {#push-testing} If you'd like to test in-app and push notifications via the command line, you can send a single notification through the terminal via CURL and the [messaging API]({{site.baseurl}}/api/endpoints/messaging/send_messages/post_send_messages/). You will need to replace the following fields with the correct values for your test case: From 14b3af6d3a7caa3489468f28ed6d15dd8afec8ec Mon Sep 17 00:00:00 2001 From: Daniel Hok Date: Thu, 5 Sep 2024 18:10:19 -0400 Subject: [PATCH 2/5] add note for Android --- .../android/customization/custom_event_callback.md | 3 +++ .../swift/push_notifications/integration.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md b/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md index 795441ca3f6..1707b72989d 100644 --- a/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md +++ b/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md @@ -86,3 +86,6 @@ Braze.getInstance(context).subscribeToPushNotificationEvents { event -> With notification action buttons, `BRAZE_PUSH_INTENT_NOTIFICATION_OPENED` intents fire when buttons with `opens app` or `deep link` actions are clicked. Deep link and extras handling remains the same. Buttons with `close` actions don't fire `BRAZE_PUSH_INTENT_NOTIFICATION_OPENED` intents and dismiss the notification automatically. {% endalert %} +{% alert tip %} +If you want your push notification listener to be triggered upon clicking on a notification while in the terminated state, you should create your listener in `Application.onCreate`. This will ensure that the listener is set up prior to processing the push click. +{% endalert %} diff --git a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md index 684aed59051..4d13a46923d 100644 --- a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md +++ b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md @@ -363,7 +363,7 @@ When using the automatic push integration, `subscribeToUpdates(_:)` is the only {% endalert %} {% alert tip %} -If you want your push notification subscription to be triggered upon clicking on a notification while in the terminated state, you should set your subscription in `application(_:didFinishLaunchingWithOptions:)`. This will ensure that the subscription is set up prior to processing the push click. +If you want your push notification subscription to be triggered upon clicking on a notification while in the terminated state, you should create your subscription in `application(_:didFinishLaunchingWithOptions:)`. This will ensure that the subscription is set up prior to processing the push click. {% endalert %} ## Testing {#push-testing} From 56307cbfc58224b816716eb9deeaca86f0cc1df1 Mon Sep 17 00:00:00 2001 From: isaiah robinson <95643215+internetisaiah@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:42:06 -0700 Subject: [PATCH 3/5] Update custom_event_callback.md --- .../android/customization/custom_event_callback.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md b/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md index 1707b72989d..e78ab957f9e 100644 --- a/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md +++ b/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md @@ -86,6 +86,6 @@ Braze.getInstance(context).subscribeToPushNotificationEvents { event -> With notification action buttons, `BRAZE_PUSH_INTENT_NOTIFICATION_OPENED` intents fire when buttons with `opens app` or `deep link` actions are clicked. Deep link and extras handling remains the same. Buttons with `close` actions don't fire `BRAZE_PUSH_INTENT_NOTIFICATION_OPENED` intents and dismiss the notification automatically. {% endalert %} -{% alert tip %} -If you want your push notification listener to be triggered upon clicking on a notification while in the terminated state, you should create your listener in `Application.onCreate`. This will ensure that the listener is set up prior to processing the push click. +{% alert important %} +Create your push notification listener in `Application.onCreate` to ensure your listener is trigger after an end-user taps a notification while your app is in a terminated state. {% endalert %} From fcd5c7e51eadd6a1c3dffa47ff91deb19d1ad0a7 Mon Sep 17 00:00:00 2001 From: isaiah robinson <95643215+internetisaiah@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:46:57 -0700 Subject: [PATCH 4/5] Update _docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md --- .../swift/push_notifications/integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md index 4d13a46923d..91473199fe8 100644 --- a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md +++ b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md @@ -363,7 +363,7 @@ When using the automatic push integration, `subscribeToUpdates(_:)` is the only {% endalert %} {% alert tip %} -If you want your push notification subscription to be triggered upon clicking on a notification while in the terminated state, you should create your subscription in `application(_:didFinishLaunchingWithOptions:)`. This will ensure that the subscription is set up prior to processing the push click. +Create your push notification subscription in `application(_:didFinishLaunchingWithOptions:)` to ensure your subscription is trigger after an end-user taps a notification while your app is in a terminated state. {% endalert %} ## Testing {#push-testing} From aa803f8c5ca5f9d10dfe17453df05c856034d923 Mon Sep 17 00:00:00 2001 From: isaiah robinson <95643215+internetisaiah@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:47:41 -0700 Subject: [PATCH 5/5] Apply suggestions from code review --- .../android/customization/custom_event_callback.md | 2 +- .../swift/push_notifications/integration.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md b/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md index e78ab957f9e..be8be785eff 100644 --- a/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md +++ b/_docs/_developer_guide/platform_integration_guides/android/push_notifications/android/customization/custom_event_callback.md @@ -87,5 +87,5 @@ With notification action buttons, `BRAZE_PUSH_INTENT_NOTIFICATION_OPENED` intent {% endalert %} {% alert important %} -Create your push notification listener in `Application.onCreate` to ensure your listener is trigger after an end-user taps a notification while your app is in a terminated state. +Create your push notification listener in `Application.onCreate` to ensure your listener is triggered after an end-user taps a notification while your app is in a terminated state. {% endalert %} diff --git a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md index 91473199fe8..809cff59de0 100644 --- a/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md +++ b/_docs/_developer_guide/platform_integration_guides/swift/push_notifications/integration.md @@ -363,7 +363,7 @@ When using the automatic push integration, `subscribeToUpdates(_:)` is the only {% endalert %} {% alert tip %} -Create your push notification subscription in `application(_:didFinishLaunchingWithOptions:)` to ensure your subscription is trigger after an end-user taps a notification while your app is in a terminated state. +Create your push notification subscription in `application(_:didFinishLaunchingWithOptions:)` to ensure your subscription is triggered after an end-user taps a notification while your app is in a terminated state. {% endalert %} ## Testing {#push-testing}