This guide is for the v4 Android SDK. We recommend upgrading to our latest v5 User Model SDKs. See Mobile SDKs API Migration Guides to upgrade the OneSignal SDK.
- Receive data in the background with or without displaying a notification.
- Override specific notification settings depending on client side app logic such as custom accent color, vibration pattern, or other any other
NotificationCompatoptions available. See Android’s documentation on the NotificationCompat options.
🚧 Requires writing Native Android code & Upgraded SDK.Must be using OneSignal SDK Versions:
- Android 4.0.0 - 4.9.9
- React Native 4.0.0 - 4.9.9
- Flutter 3.0.0 - 3.9.9
- Cordova/Ionic 3.0.0 - 3.9.9
- Unity 3.0.0 - 3.9.9
- Xamarin 4.0.0 - 4.9.9
Step 1. Create a class for the Service Extension
Create a class that extendsOSRemoteNotificationReceivedHandler and implement the remoteNotificationReceived method.
The method remoteNotificationReceived parameters are context of type Context and notificationReceivedEvent of type OSNotificationReceivedEvent.
Step 2. Add the following to your AndroidManifest.xml.
Add OneSignal class name and your class value as meta-data within the AndroidManifest.xml file under the application tag. Ignore any “unused” warnings.