Traveling Foreground notification customizations
- Add a custom Activity
When adding
custom_more_info_activity
, the SDK launches the app's Activity instead of its own Webview Activity when tapping the foreground notification's More Info button. This custom Activity should include a privacy policy and options for the user to opt-out of data collection. See 3.c for more information.Note: Do not include these optional meta-data values unless explicitly using the features they support.<!-- Optional: Do not include this field unless the App has an Activity for displaying the privacy policy and opt-out. Whether to open a custom Activity within the app when tapping the Sense360 foreground notification's "More Info" button --> <meta-data android:name="com.sense360.custom_more_info_activity" android:value="com.example.CustomActivity" />
- Add the foreground service permissionAdd this permission to
AndroidManifest.xml
.<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
- (Optional) Customize the foreground notification at runtime.
- Pass
null
for theForegroundServiceConfig
If you pass innull
for theForegroundServiceConfig
object, it uses the default defined in theAndroidManifest.xml
in step 2. If you do not want to update the notification at runtime, do not make a call toSense360.updateForegroundService
. - Pass non-null values Pass non-null values for
newTitle
andnewMessage
ifisEnabled = true
:boolean isEnabled = true; Boolean clickOpensApp = false; String newTitle = "Searching for surveys..."; String newMessage = "Searching for location-based surveys..."; ForegroundServiceConfig newConfig = new ForegroundServiceConfig(isEnabled, clickOpensApp, newTitle, newMessage); //Replace "ic_notification_icon" with your notification icon namenewConfig.passNotificationIconId(R.drawable.ic_notification_icon); Sense360.updateForegroundService(getActivity().getApplicationContext(), newConfig);
- Pass a valid Activity name For the Sense360 notification's More Info button to open your Activity instead of the Sense360 Webview Activity to display your privacy policy and opt-out. This Activity must be within your own app, into which the Sense360 SDK is integrated. If the Activity associated with the Activity name is unavailable, the SDK defaults to display its own notification with the More Info button opening the Sense360 privacy policy page and opt-out option. This Activity name is entirely optional and not required for complete functionality of the SDK.
boolean isEnabled = true; Boolean clickOpensApp = false; String newTitle = "Searching for surveys..."; String newMessage = "Searching for location-based surveys..."; ForegroundServiceConfig newConfig = new ForegroundServiceConfig(isEnabled, clickOpensApp, newTitle, newMessage); //Replace "ic_notification_icon" with your notification icon namenewConfig.passNotificationIconId(R.drawable.ic_notification_icon); Sense360.updateForegroundService(getActivity().getApplicationContext(), newConfig);
- Pass a valid Activity name For the Sense360 notification's click-action (not the More Info button) to open a specific Activity when tapping the notification. This Activity must be within your own app integrated to the Sense360 SDK. This Activity name is entirely optional and not required for complete functionality of the SDK.
<meta-data android:name="com.sense360.foreground_notification_click_opens_app" android:value="true" /> //Replace com.example.CustomActivity with your app's own Activity <meta-data android:name="com.sense360.custom_launch_activity" android:value="com.example.CustomActivity" />
To dynamically pass in theCustomActivity
, use this code snippet:boolean isEnabled = true; Boolean clickOpensApp = true; String newTitle = "Searching for surveys..."; String newMessage = "Searching for location based surveys..."; ForegroundServiceConfig newConfig = new ForegroundServiceConfig(isEnabled, clickOpensApp, newTitle, newMessage); //Replace "CustomActivity" with your Activity's namenewConfig.passCustomLaunchActivityName(CustomActivity.class.getName()); Sense360.updateForegroundService(getActivity().getApplicationContext(), newConfig);
- Pass
- Get current Foreground notification configuration
ForegroundServiceConfig config = Sense360.getForegroundServiceDetails(getActivity().getApplicationContext());