Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/_partials/_silentNotification_Code.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Admonition, TabItem, Tabs } from "@site/src/components/forDocs";

3. Implement background handler in `AppDelegate`.

<Tabs groupId="ios-languages">
<TabItem value="Objective-C" label="Objective-C">
```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];
}
}

````
</TabItem>
<TabItem value="Swift" label="Swift">
```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
}
````

</TabItem>
</Tabs>
18 changes: 18 additions & 0 deletions docs/_partials/_silentNotification_iOS.mdx
Original file line number Diff line number Diff line change
@@ -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.
Comment thread
IamJoyson marked this conversation as resolved.
- 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_**

<Image width="full !p-0" src="/static/books/sdkx_ios/background-modes.png" />
44 changes: 23 additions & 21 deletions docs/sdkx-cocos2dx/proactive-engagement.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

<Intro>

Expand Down Expand Up @@ -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.

<Image
src="/static/books/common/proactive-admin-compose.png"
Expand All @@ -55,8 +57,8 @@ To publish a notification follow these steps:
/>

- 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)

<Image
src="/static/books/common/proactive-admin-audience.png"
Expand Down Expand Up @@ -145,7 +147,7 @@ Otherwise, follow the setup instructions on the
<InAppSample platform="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.
Expand All @@ -158,7 +160,6 @@ Otherwise, follow the setup instructions on the

<AndroidiOSProactiveNotifBehaviourTable />


## 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.
Expand All @@ -175,12 +176,12 @@ Otherwise, follow the setup instructions on the

<div className="compact ">

| 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()` |

</div>

Expand All @@ -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.
Expand All @@ -211,12 +211,12 @@ The following configurations are available via this API:

<div className="compact ">

| 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()` |

</div>

Expand Down Expand Up @@ -246,20 +246,19 @@ 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".

For more details on these configuration options and custom notification channels, please refer to the [Android Notification Defaults](/sdkx-cocos2dx/notifications-android/#notification-defaults) section.

## 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()`.
Expand Down Expand Up @@ -326,3 +325,6 @@ bool HelloWorld::init()
HelpshiftCocos2dx::setHelpshiftProactiveConfigCollector(getAPIConfig);
}
```

<SilentNotifications />
<SilentNotificationCode />
88 changes: 66 additions & 22 deletions docs/sdkx-react-native/proactive-engagement.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

<Intro>

Expand Down Expand Up @@ -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.

<Image
src="/static/books/common/proactive-admin-compose.png"
Expand All @@ -56,8 +58,8 @@ To publish a notification follow these steps:
/>

- 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)

<Image
src="/static/books/common/proactive-admin-audience.png"
Expand Down Expand Up @@ -146,7 +148,7 @@ Otherwise, follow the setup instructions on the
<InAppSample platform="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.
Expand Down Expand Up @@ -175,12 +177,12 @@ Otherwise, follow the setup instructions on the

<div className="compact ">

| 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()` |

</div>

Expand All @@ -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.
Expand All @@ -211,12 +212,12 @@ The following configurations are available via this API:

<div className="compact ">

| 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()` |

</div>

Expand All @@ -225,8 +226,8 @@ Example:
```javascript
import {
install,
setAndroidProactivePushNotificationDefaults
} from 'helpshift-plugin-sdkx-react-native';
setAndroidProactivePushNotificationDefaults,
} from "helpshift-plugin-sdkx-react-native";

// ... install call ...

Expand All @@ -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);
Expand All @@ -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".

Expand Down Expand Up @@ -274,4 +276,46 @@ const proactiveConfig = {
};

setProactiveConfig(proactiveConfig);
```
```

<SilentNotifications />

3. Implement background handler in `AppDelegate`.

<Tabs groupId="ios-languages">
<TabItem value="Objective-C" label="Objective-C">
```objc
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
[RNNotifications didReceiveBackgroundNotification:userInfo withCompletionHandler:completionHandler];
}

````
</TabItem>
<TabItem value="Swift" label="Swift">
```swift
override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
RNNotifications.didReceiveBackgroundNotification(userInfo, withCompletionHandler: completionHandler)
}
````

</TabItem>
</Tabs>

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);
}
},
);
```
Loading