diff --git a/docs/_partials/_silentNotification_Code.mdx b/docs/_partials/_silentNotification_Code.mdx new file mode 100644 index 00000000..022a2693 --- /dev/null +++ b/docs/_partials/_silentNotification_Code.mdx @@ -0,0 +1,37 @@ +import { Admonition, TabItem, Tabs } from "@site/src/components/forDocs"; + +3. Implement background handler in `AppDelegate`. + + + +```objc +- (void)application:(UIApplication *)application +didReceiveRemoteNotification:(NSDictionary *)userInfo +fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + + NSString *origin = userInfo[@"origin"]; + + if ([origin isKindOfClass:[NSString class]] && [origin isEqualToString:@"helpshift"]) { + // Call the Helpshift background handler and pass the completion block + [Helpshift handleSilentBackgroundNotification:userInfo withCompletionHandler:completionHandler]; + } +} + +```` + + +```swift + func application( + _ application: UIApplication, + didReceiveRemoteNotification userInfo: [AnyHashable : Any] + ) async -> UIBackgroundFetchResult { + let origin = userInfo["origin"] as? String + if origin == "helpshift" { + return await Helpshift.handleSilentBackgroundNotification(userInfo) + } + return .noData + } +```` + + + diff --git a/docs/_partials/_silentNotification_iOS.mdx b/docs/_partials/_silentNotification_iOS.mdx new file mode 100644 index 00000000..2b286f11 --- /dev/null +++ b/docs/_partials/_silentNotification_iOS.mdx @@ -0,0 +1,18 @@ +import { Image } from "@site/src/components/forDocs"; + +## Handling Silent Notification for In-App Proactive Engagement Notifications + +By default, In-App notifications are sent directly to the device's notification tray, as fallback push notifications, if your application is in background/killed state. +However, you can configure the SDK to display notification exclusively as In-App notification and show up only when the user is actively using the app. + +- If the app is terminated by the system, silent pushes may not wake it. +- Background delivery is not guaranteed: silent notifications are best-effort and may be delayed or dropped when the system is low on resources or the app has been force-quit. +- When silent notifications are enabled/handled in your app but fallback push is disabled, you can't use this feature to reach or re-engage inactive users. In-App notifications are displayed only when the app is in the foreground. + +#### Implementation Steps + +1. Enable background remote notifications in Xcode: + +> **_Xcode → Capabilities → Background Modes → Remote Notifications_** + + diff --git a/docs/sdkx-cocos2dx/proactive-engagement.mdx b/docs/sdkx-cocos2dx/proactive-engagement.mdx index 268bbc48..74445295 100644 --- a/docs/sdkx-cocos2dx/proactive-engagement.mdx +++ b/docs/sdkx-cocos2dx/proactive-engagement.mdx @@ -11,11 +11,13 @@ import { TabItem, Tabs, Image, - Centered + Centered, } from "@site/src/components/forDocs"; import AndroidiOSProactiveNotifBehaviourTable from "@site/docs/_partials/_androidAndiOSProactiveNotifBehaviourTable.mdx"; import InAppSample from "@site/docs/_partials/_proactiveAnd_inappSamples.mdx"; +import SilentNotifications from "@site/docs/_partials/_silentNotification_iOS.mdx"; +import SilentNotificationCode from "@site/docs/_partials/_silentNotification_Code.mdx"; @@ -46,7 +48,7 @@ To publish a notification follow these steps: /> - Select the desired action from available options, fill up the notification content and add context as per your needs. - - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. + - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. - Configure the audience filter that you want to target. You can filter the audience based on: - - Issue properties - - User properties [using User Hub integration](/sdkx-cocos2dx/identity-user-hub) + - Issue properties + - User properties [using User Hub integration](/sdkx-cocos2dx/identity-user-hub) - In-App notifications are used to grab attention of the user who is already using your application, is on the application UI and you want to alert or engage with him in real time. -- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. +- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. - When the user clicks on the notification we open the app and then present the actual configured in-app notification. This increases the probability of user engagement and helps us achieve our goal better. - We currently support Banner type notifications with click actions similar to Push notifications. - If the SDK receives multiple in-app notifications when the app was in background then the system will display all of them. On clicking the notification, we will open the app and the SDK will show in-app notification corresponding to the clicked notification. Other notifications remain as is in the notification center. @@ -158,7 +160,6 @@ Otherwise, follow the setup instructions on the - ## Pausing In-App Notifications {/* #pausing-in-app-notifications */} - This API will pause/unpause the showing of in-app notifications to the end user when the application is in the foreground. @@ -175,12 +176,12 @@ Otherwise, follow the setup instructions on the
-| Key | Details | -| --- | --- | -| **API** | `pauseDisplayOfInAppNotification(shouldPause: bool)` | -| **Values** | `true` (Pauses), `false` (Resumes) | -| **Min SDK** | v10.5.0 | -| **Note** | After calling `HelpshiftCocos2dx::install()` | +| Key | Details | +| ----------- | ---------------------------------------------------- | +| **API** | `pauseDisplayOfInAppNotification(shouldPause: bool)` | +| **Values** | `true` (Pauses), `false` (Resumes) | +| **Min SDK** | v10.5.0 | +| **Note** | After calling `HelpshiftCocos2dx::install()` |
@@ -196,7 +197,6 @@ HelpshiftCocos2dx::pauseDisplayOfInAppNotification(true); HelpshiftCocos2dx::pauseDisplayOfInAppNotification(false); ``` - ## Setting defaults for notification properties (Android) {/* #notification-defaults */} If you need to set some defaults to be used in proactive notifications on Android, you can use the `setAndroidProactivePushNotificationDefaults` API. We recommend calling this API right after the `install()` call. @@ -211,12 +211,12 @@ The following configurations are available via this API:
-| Key | Details | -| --- | --- | -| **API** | `setAndroidProactivePushNotificationDefaults(config: object)` | -| **Platform** | Android only | -| **Min SDK** | v10.5.0 | -| **Note** | After calling `HelpshiftCocos2dx::install()` | +| Key | Details | +| ------------ | ------------------------------------------------------------- | +| **API** | `setAndroidProactivePushNotificationDefaults(config: object)` | +| **Platform** | Android only | +| **Min SDK** | v10.5.0 | +| **Note** | After calling `HelpshiftCocos2dx::install()` |
@@ -246,12 +246,12 @@ public class MyActivity extends Cocos2dxActivity { } ``` - ### Custom notification channels for Proactive Engagement notifications {/* #custom-channels */} If you want to use your own notification channels (created by your application beforehand) for Proactive Engagement notifications, you can provide the channel IDs via the API above. If the values are not set, the SDK creates default notification channels automatically: + - **Proactive Support**: For notifications leading to Helpcenter or Conversations. Default name: "Proactive Support". - **Proactive Engage**: For notifications leading to user engagement. Default name: "Proactive Engage". @@ -259,7 +259,6 @@ For more details on these configuration options and custom notification channels ## Passing configuration specific to the current user {/* #user-specific-config */} - You may want to add configuration specific to the current user in your app when they click on the notification. Setting local API config enables the Helpshift SDK to merge configuration from both, the config embedded in the outbound support link (as mentioned in previous steps) and the local config provided at runtime. This local API config is exactly same as we would expect in other APIs like `showConversation()` or `showFAQs()`. @@ -326,3 +325,6 @@ bool HelloWorld::init() HelpshiftCocos2dx::setHelpshiftProactiveConfigCollector(getAPIConfig); } ``` + + + diff --git a/docs/sdkx-react-native/proactive-engagement.mdx b/docs/sdkx-react-native/proactive-engagement.mdx index d35e173a..f659986d 100644 --- a/docs/sdkx-react-native/proactive-engagement.mdx +++ b/docs/sdkx-react-native/proactive-engagement.mdx @@ -11,11 +11,13 @@ import { TabItem, Tabs, Image, - Centered + Centered, } from "@site/src/components/forDocs"; import AndroidiOSProactiveNotifBehaviourTable from "@site/docs/_partials/_androidAndiOSProactiveNotifBehaviourTable.mdx"; import InAppSample from "@site/docs/_partials/_proactiveAnd_inappSamples.mdx"; +import SilentNotifications from "@site/docs/_partials/_silentNotification_iOS.mdx"; +import SilentNotificationCode from "@site/docs/_partials/_silentNotification_Code.mdx"; @@ -47,7 +49,7 @@ To publish a notification follow these steps: /> - Select the desired action from available options, fill up the notification content and add context as per your needs. - - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. + - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. - Configure the audience filter that you want to target. You can filter the audience based on: - - Issue properties - - User properties [using User Hub integration](/sdkx-react-native/identity-user-hub) + - Issue properties + - User properties [using User Hub integration](/sdkx-react-native/identity-user-hub) - In-App notifications are used to grab attention of the user who is already using your application, is on the application UI and you want to alert or engage with him in real time. -- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. +- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. - When the user clicks on the notification we open the app and then present the actual configured in-app notification. This increases the probability of user engagement and helps us achieve our goal better. - We currently support Banner type notifications with click actions similar to Push notifications. - If the SDK receives multiple in-app notifications when the app was in background then the system will display all of them. On clicking the notification, we will open the app and the SDK will show in-app notification corresponding to the clicked notification. Other notifications remain as is in the notification center. @@ -175,12 +177,12 @@ Otherwise, follow the setup instructions on the
-| Key | Details | -| --- | --- | -| **API** | `pauseDisplayOfInAppNotification(shouldPause: boolean)` | -| **Values** | `true` (Pauses), `false` (Resumes) | -| **Min SDK** | v10.5.0 | -| **Call Timing** | After `install()` | +| Key | Details | +| --------------- | ------------------------------------------------------- | +| **API** | `pauseDisplayOfInAppNotification(shouldPause: boolean)` | +| **Values** | `true` (Pauses), `false` (Resumes) | +| **Min SDK** | v10.5.0 | +| **Call Timing** | After `install()` |
@@ -196,7 +198,6 @@ pauseDisplayOfInAppNotification(true); pauseDisplayOfInAppNotification(false); ``` - ## Setting defaults for notification properties (Android) {/* #notification-defaults */} If you need to set some defaults to be used in proactive notifications on Android, you can use the `setAndroidProactivePushNotificationDefaults` API. We recommend calling this API right after the `install()` call. @@ -211,12 +212,12 @@ The following configurations are available via this API:
-| Key | Details | -| --- | --- | -| **API** | `setAndroidProactivePushNotificationDefaults(config: object)` | -| **Platform** | Android only | -| **Min SDK** | v10.5.0 | -| **Call Timing** | Right after `install()` | +| Key | Details | +| --------------- | ------------------------------------------------------------- | +| **API** | `setAndroidProactivePushNotificationDefaults(config: object)` | +| **Platform** | Android only | +| **Min SDK** | v10.5.0 | +| **Call Timing** | Right after `install()` |
@@ -225,8 +226,8 @@ Example: ```javascript import { install, - setAndroidProactivePushNotificationDefaults -} from 'helpshift-plugin-sdkx-react-native'; + setAndroidProactivePushNotificationDefaults, +} from "helpshift-plugin-sdkx-react-native"; // ... install call ... @@ -235,7 +236,7 @@ const proactiveDefaults = { largeNotificationIconId: "ic_large_notification", soundId: "notification_sound", proactiveSupportChannelId: "my_support_channel", - proactiveEngageChannelId: "my_engage_channel" + proactiveEngageChannelId: "my_engage_channel", }; setAndroidProactivePushNotificationDefaults(proactiveDefaults); @@ -246,6 +247,7 @@ setAndroidProactivePushNotificationDefaults(proactiveDefaults); If you want to use your own notification channels (created by your application beforehand) for Proactive Engagement notifications, you can provide the channel IDs via the API above. If the values are not set, the SDK creates default notification channels automatically: + - **Proactive Support**: For notifications leading to Helpcenter or Conversations. Default name: "Proactive Support". - **Proactive Engage**: For notifications leading to user engagement. Default name: "Proactive Engage". @@ -274,4 +276,46 @@ const proactiveConfig = { }; setProactiveConfig(proactiveConfig); -``` \ No newline at end of file +``` + + + +3. Implement background handler in `AppDelegate`. + + + +```objc +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { + [RNNotifications didReceiveBackgroundNotification:userInfo withCompletionHandler:completionHandler]; +} + +```` + + +```swift +override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], + fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + RNNotifications.didReceiveBackgroundNotification(userInfo, withCompletionHandler: completionHandler) +} +```` + + + + +4. Add RN Notification listener for background notifications. + +```javascript +Notifications.events().registerNotificationReceivedBackground( + async (notification, completion) => { + const notificationData = notification.payload; + const doesNotificationDataHaveOrigin = + notificationData?.origin === "helpshift"; + if (doesNotificationDataHaveOrigin) { + const value = await handleIOSSilentNotification(notificationData); + completion(NotificationBackgroundFetchValue[value]); + } else { + completion(NotificationBackgroundFetchResult.NEW_DATA); + } + }, +); +``` diff --git a/docs/sdkx-unity/proactive-engagement-ios.mdx b/docs/sdkx-unity/proactive-engagement-ios.mdx index d455d9b8..c8b78c24 100644 --- a/docs/sdkx-unity/proactive-engagement-ios.mdx +++ b/docs/sdkx-unity/proactive-engagement-ios.mdx @@ -10,8 +10,10 @@ import { Intro, TabItem, Tabs, - Image + Image, } from "@site/src/components/forDocs"; +import SilentNotifications from "@site/docs/_partials/_silentNotification_iOS.mdx"; +import SilentNotificationCode from "@site/docs/_partials/_silentNotification_Code.mdx"; import InAppSample from "@site/docs/_partials/_proactiveAnd_inappSamples.mdx"; import ProactiveNotifBehaviourTable from "@site/docs/_partials/_iOSProactiveNotifBehaviourTable.mdx"; @@ -46,7 +48,7 @@ To publish a notification follow these steps: /> - Select the desired action from available options, fill up the notification content and add context as per your needs. - - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. + - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. - Configure the audience filter that you want to target. You can filter the audience based on: - - Issue properties - - User properties [using User Hub integration](/sdkx-unity/identity-user-hub-ios) + - Issue properties + - User properties [using User Hub integration](/sdkx-unity/identity-user-hub-ios) - In-App notifications are used to grab attention of the user who is already using your application, is on the application UI and you want to alert or engage with him in real time. -- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. +- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. - When the user clicks on the notification we open the app and then present the actual configured in-app notification. This increases the probability of user engagement and helps us achieve our goal better. - We currently support Banner type notifications with click actions similar to Push notifications. - If the SDK receives multiple in-app notifications when the app was in background then the system will display all of them. On clicking the notification, we will open the app and the SDK will show in-app notification corresponding to the clicked notification. Other notifications remain as is in the notification center. @@ -174,9 +176,12 @@ For example, following code shows how to implement `HelpshiftProactiveAPIConfigC } ``` + + + - You need to call this API after `Install` API and before `handleBackgroundNotificationClick:withCompletionHandler:` - The "customIssueFields" key has been deprecated. We strongly recommend transitioning to using the "cifs" key as the preferred method for passing custom issue fields. - \ No newline at end of file + diff --git a/docs/sdkx_ios/proactive-engagement.mdx b/docs/sdkx_ios/proactive-engagement.mdx index 8ca2dc3e..6af05cc5 100644 --- a/docs/sdkx_ios/proactive-engagement.mdx +++ b/docs/sdkx_ios/proactive-engagement.mdx @@ -10,10 +10,12 @@ import { Intro, TabItem, Tabs, - Image + Image, } from "@site/src/components/forDocs"; import ProactiveNotifBehaviourTable from "@site/docs/_partials/_iOSProactiveNotifBehaviourTable.mdx"; +import SilentNotifications from "@site/docs/_partials/_silentNotification_iOS.mdx"; +import SilentNotificationCode from "@site/docs/_partials/_silentNotification_Code.mdx"; import InAppSample from "@site/docs/_partials/_proactiveAnd_inappSamples.mdx"; @@ -46,7 +48,7 @@ To publish a notification follow these steps: /> - Select the desired action from available options, fill up the notification content and add context as per your needs. - - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. + - Intents/CIFs/tags/initial message etc configured here will be used when the end user starts a conversation by clicking on the notification. - Configure the audience filter that you want to target. You can filter the audience based on: - - Issue properties - - User properties [using User Hub integration](/sdkx_ios/identity-user-hub) + - Issue properties + - User properties [using User Hub integration](/sdkx_ios/identity-user-hub) - In-App notifications are used to grab attention of the user who is already using your application, is on the application UI and you want to alert or engage with him in real time. -- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. +- If the user is not on the application UI then the notification is shown in the notification tray of the device to engage the user. - When the user clicks on the notification we open the app and then present the actual configured in-app notification. This increases the probability of user engagement and helps us achieve our goal better. - We currently support Banner type notifications with click actions similar to Push notifications. - If the SDK receives multiple in-app notifications when the app was in background then the system will display all of them. On clicking the notification, we will open the app and the SDK will show in-app notification corresponding to the clicked notification. Other notifications remain as is in the notification center. @@ -180,4 +182,7 @@ func getAPIConfig() -> Dictionary { - You need to call this API after `install` API and before `handleBackgroundNotificationClick:withCompletionHandler:` - The "customIssueFields" key has been deprecated. We strongly recommend transitioning to using the "cifs" key as the preferred method for passing custom issue fields. - \ No newline at end of file + + + + diff --git a/static/static/books/sdkx_ios/background-modes.png b/static/static/books/sdkx_ios/background-modes.png new file mode 100644 index 00000000..aa4df498 Binary files /dev/null and b/static/static/books/sdkx_ios/background-modes.png differ