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..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 @@ -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 important %} +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 22d63462ffa..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 @@ -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 %} +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} 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: