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..6f2984ac --- /dev/null +++ b/docs/_partials/_silentNotification_iOS.mdx @@ -0,0 +1,19 @@ +import { Image } from "@site/src/components/forDocs"; +import AndroidInAppSample from "@site/docs/_partials/_proactiveAnd_inappSamples.mdx"; + +## Handling Silent notification for in-app + +By default, in-app notifications are sent directly to the device's notification tray as fallback push notifications. +However, you can configure the SDK to display notification exclusively as in-app notification while 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 and fallback push is disabled, you can't use this feature to reach or re-engage inactive users. Because in-app notifications only appear 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 cfd5a4a7..d1e1d161 100644 --- a/docs/sdkx-cocos2dx/proactive-engagement.mdx +++ b/docs/sdkx-cocos2dx/proactive-engagement.mdx @@ -16,6 +16,8 @@ import { import AndroidiOSProactiveNotifBehaviourTable from "@site/docs/_partials/_androidAndiOSProactiveNotifBehaviourTable.mdx"; import AndroidInAppSample 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"; @@ -330,3 +332,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 fb781a21..d238551f 100644 --- a/docs/sdkx-react-native/proactive-engagement.mdx +++ b/docs/sdkx-react-native/proactive-engagement.mdx @@ -16,6 +16,8 @@ import { import AndroidiOSProactiveNotifBehaviourTable from "@site/docs/_partials/_androidAndiOSProactiveNotifBehaviourTable.mdx"; import AndroidInAppSample 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"; @@ -278,4 +280,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 5dae7b3d..bd506db4 100644 --- a/docs/sdkx-unity/proactive-engagement-ios.mdx +++ b/docs/sdkx-unity/proactive-engagement-ios.mdx @@ -12,6 +12,8 @@ import { Tabs, 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 ProactiveNotifBehaviourTable from "@site/docs/_partials/_iOSProactiveNotifBehaviourTable.mdx"; @@ -177,6 +179,9 @@ For example, following code shows how to implement `HelpshiftProactiveAPIConfigC } ``` + + + - You need to call this API after `Install` API and before `handleBackgroundNotificationClick:withCompletionHandler:` diff --git a/docs/sdkx_ios/proactive-engagement.mdx b/docs/sdkx_ios/proactive-engagement.mdx index d9d0548b..e3a6ad35 100644 --- a/docs/sdkx_ios/proactive-engagement.mdx +++ b/docs/sdkx_ios/proactive-engagement.mdx @@ -14,6 +14,8 @@ import { } 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"; @@ -183,4 +185,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