Customize Android SDK
- Deep Linking
- In-app purchase tracking
- Using Local Notifications
- Using Badge Number
- Opening custom activity
- Controlling log level
- Using Proguard
- Customizing notifications open behavior
- Customizing push notifications
- Customizing group summary
- Private endpoint URL
- Creating a Rich Media queue
- Custom sound push
- Complete list of Android SDK Feature Flags
- Deleting push notifications via TTL (Time-To-Live)
Deep linking
In your activity that will handle the deep link, add <data> tag with the scheme, host, and pathPrefix parameters.
In the example above, the deep link will open PromoActivity. The basic implementation below displays alert with promo id value for the sake of simplicity. In your application it could definitely do something useful!
In-app purchase tracking
If you want to track in-app purchases in Customer Journeys, configure sending purchase information to Pushwoosh by calling this method:
Using Local Notifications with Pushwoosh
If you use Pushwoosh Local Notifications API, add RECEIVE_BOOT_COMPLETED permission to your AndroidManifest.xml:
Using badge number on Android
Pushwoosh supports setting badge number on the app icon shortcut for the following Android launchers:
Sony, Samsung, LG, HTC, Xiaomi, ASUS, ADW, APEX, NOVA, HUAWEI, ZUK, OPPO.
To use this functionality, simply add com.pushwoosh:pushwoosh-badge
library to your application.
Opening custom activity
If you want to start a particular activity in response to push notifications, add the following intent-filter to that activity:
Controlling Log Level
In order to assist with debugging and integration, SDK will print all the requests to the console by default. When you are ready for the production build, add com.pushwoosh.log_level
meta-data with value “ERROR” to the AndroidManifest.xml. This way only information about errors will go to the console. Other option could be one of the following:
NONE - No logs from the SDK
ERROR - Display only errors in the console
WARN - Display also a warnings
INFO - Display informational messages
DEBUG - Even debug information is displayed now
NOISE - Everything SDK can print and more
Using Proguard
When using Proguard, add the following options:
See Google Play Services library requirements regarding Proguard here:
https://developers.google.com/android/guides/setup
Customising notification open behaviour
If you need to programmatically select which activity to display as a result of push notification, you can create custom NotificationServiceExtension and include fully qualified class name of your NotificationServiceExtension in metadata under com.pushwoosh.notification_service_extension
value.
Customizing push notifications
To customize the view of push notifications, you need to create a custom Factory, you can create custom NotificationFactory and include fully qualified class name of your NotificationFactory in metadata under com.pushwoosh.notification_factory
value.
Customizing group summary
To customize the appearance of a group summary, create a custom Factory. You can create custom SummaryNotificationFactory and include fully qualified class name of your SummaryNotificationFactory in metadata under com.pushwoosh.summary_notification_factory value.
Private endpoint URL
Pushwoosh provides Private endpoints for customers with Custom Plan subscriptions. To set up Private endpoint for Android SDK, you need to add the following to your AndroidManifest.xml file:
Creating a Rich Media queue
In case there are several Rich Media pages to display simultaneously (for example, trigger events for two or more In-Apps take place at one moment, or a Rich Media page is being displayed already at the moment a different trigger event occurs), you can set up a queue for Rich Media pages displaying. To create a queue, add the following code to your project:
Custom sound push
- Put your audio file in the proper folder. For the native Android framework, your files should be placed in the
/app/src/main/res/raw
folder.
2. Create a Notification Channel.
3. Select a sound while configuring a push message.
4. Set the Notification Channel the message will belong to. To do so, specify the following in the “Android root params” field:{"pw_channel": "PUSH NOTIFICATION CHANNEL NAME"} //``
here you need to specify the name for your channel with custom sound
In case of using remote API, set the parameters as follows within your /createMessage API request:
Once you send the push with those params specified, the Notification Channel with the selected sound is created for all devices with Android 8+.
Now, to send the push with a custom sound, you have to specify only the channel associated with that sound.
Proguard rules for custom notification sounds
If your app uses proguard for code and resource shrinking, it is important to keep your sound files intact and available for external libraries. If you use minifyEnabled = true
property to your build.gradle, add the following rules to your proguard-rules.pro:
If you shrink resources of your app on top of code shrinking by using shrinkResources=true
property, you should additionally specify what resources you want to keep. To do that, create a new XML file with any name, save it somewhere in your project (for example, in res/xml), and specify the resource names under the tools:keep
parameter in the resources
tag:
Complete list of Android SDK meta-data flags
To set up a flag, you need to add the meta-data block to your AndroidManifest.xml file inside the application tag. For example, if you want to set the Pushwoosh application ID, add the following code to your AndroidManifest.xml file:
Flag | Description | Possible values |
---|---|---|
com.pushwoosh.appid | Sets the Pushwoosh application ID. | XXXXX-XXXXX |
com.pushwoosh.senderid | Sets the Firebase project sender ID. | 123456789000 |
com.pushwoosh.log_level | Sets logging level. For details, refer to Controlling Log Level. | NONE / ERROR / WARN / INFO / DEBUG (default) / NOISE |
com.pushwoosh.base_url | Overrides the Pushwoosh server base url. | https://cp.pushwoosh.com/json/1.3/ (default) |
com.pushwoosh.notification_service_extension | Custom NotificationServiceExtension. For details, refer to Customising Notification Open Behavior. | com.myapp.MyNotificationServiceExtension |
com.pushwoosh.notification_factory | Custom NotificationFactory. For details, refer to Customizing Push Notifications. | com.myapp.MyNotificationFactory |
com.pushwoosh.summary_notification_factory | Custom SummaryNotificationFactory. | com.myapp.MySummaryNotificationFactory |
com.pushwoosh.multi_notification_mode | If true, notification will be grouped. If false, the last received notification will be displayed only. | true / false (default) |
com.pushwoosh.allow_server_communication | If true, the SDK is allowed to send network requests to Pushwoosh servers. | true (default) / false |
com.pushwoosh.handle_notifications_using_workmanager | If true, the WorkManager is set to handle notifications. | true / false (default) |
com.pushwoosh.notification_icon | Custom notification (small) icon resource name. If null, default application icon will be used. | res/drawable-xxhdpi-v11/notification_small_icon.png / null |
com.pushwoosh.notification_icon_color | Notification (small) icon background color. | #FFFFFF |
com.pushwoosh.allow_collecting_device_data | If true, the SDK is allowed to collect and to send device data to Pushwoosh. | true (default) / false |
com.pushwoosh.allow_collecting_device_os_version | If true, the SDK is allowed to collect and to send device OS version to Pushwoosh. | true (default) / false |
com.pushwoosh.allow_collecting_device_locale | If true, the SDK is allowed to collect and to send device locale to Pushwoosh. | true (default) / false |
com.pushwoosh.allow_collecting_device_model | If true, the SDK is allowed to collect and to send device model to Pushwoosh. | true (default) / false |
com.pushwoosh.in_app_business_solutions_capping | Limits the number of times the push-unregister In-App can be shown in a day. | 1 (default), 2, …, n |
com.pushwoosh.start_foreground_service | If true, Foreground Service is launched along with the PushwooshLocation.startLocationTracking() call | true / false (default) |
com.pushwoosh.foreground_service_notification_text | Sets the text of a notification created when the Foreground Service is launched for the “com.pushwoosh.start_foreground_service” key. | Work in progress (default) |
com.pushwoosh.foreground_service_notification_channel_name | Sets the channel name for the notification created when the Foreground Service is launched for the “com.pushwoosh.start_foreground_service” key. | Foreground service (default) |
com.pushwoosh.trusted_package_names | Allows sharing Pushwoosh HWID with specified package | ”com.mycompany.myapp1, com.mycompany.myapp2” |
Deleting Push Notifications via TTL (Time-To-Live)
To automatically delete push notifications after a specified time period using TTL (Time-to-Live), follow these steps:
-
Create a Custom NotificationFactory. Learn more
-
In the
onGenerateNotification()
method, create a notification using theNotification.Builder
orNotificationCompat.Builder
class and call thesetTimeoutAfter
method:
Share Your Feedback with Us
Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.