FAQ on Pushwoosh Android SDK
Answers to the most frequently asked questions about using Pushwoosh Android SDK
What does Android push token and HWID look like?
Android device push tokens differ in length (less than 255 characters) and start with APA91b, e.g.:
APA91bFoi3lMMre9G3XzR1LrF4ZT82_15MsMdEICogXSLB8-MrdkRuRQFwNI5u8Dh0cI90ABD3BOKnxkEla8cGdisbDHl5cVIkZah5QUhSAxzx4Roa7b4xy9tvx9iNSYw-eXBYYd8k1XKf8Q_Qq1X9-x-U-Y79vdPq
Please also note that tokens often contain a colon-separated prefix before APA91b, e.g. eQnyCE6ULAQ:APA91bGrh4ya3b_owo9tshZNVAGhZdGMGb3sA5HbM...
Pushwoosh uses UUID as HWIDs, i.e. randomly generated strings of 32 alphanumerical characters: 123e4567-e89b-12d3-a456-426655440000
How can I obtain my Android device push token?
You can obtain your Android device push token in the console log. Use the logcat tool in Android Studio.
Open monitor.bat in %USERPROFILE%\AppData\Local\Android\sdk\tools\monitor.bat
, connect your device to PC and allow USB debugging in Android settings. Run your application on the device. Locate /registerDevice
, find the push token for your device to use in Test Devices later on.
What permissions are necessary and what are optional?
When installed on an Android device, the application will ask for the following permissions in connection with Pushwoosh SDK:
Our SDK doesn’t ask for permission to access images, device contacts, etc.
How do I set a UserID?
You have the option to set a User identifier (UserID), which could be a Facebook ID, username, email, or any other unique user ID. This enables you to match data and events across multiple devices associated with the same user. To set the UserID, call the setUserId method.
Example
How accurate is the total number of Android subscribers?
Pushwoosh clears unsubscribed Android devices from the database upon receiving the “NotRegistered” response from FCM, which can be returned after the second attempt to reach a specific device. It means that you have to send 2 pushes to an unsubscribed device to have it removed from our database. Here’s the most common scenario described in the FCM documentation:
Your subscriber uninstalls the app.
Pushwoosh sends a message to FCM server.
The FCM server sends the message to your user’s device.
The FCM client on the device receives the message and detects that your application has been uninstalled; the detection details depend on the platform on which the app is running.
The FCM client on the device informs the FCM server that the app was uninstalled.
The FCM server marks the registration ID for deletion.
Pushwoosh sends another message to FCM.
The FCM returns a NotRegistered message.
Pushwoosh removes the push token from your userbase.
It might take a while for registration ID to be completely removed from FCM. Thus it is possible a message sent in step 7 above gets a valid message ID as response, even though the message will not be delivered to the client app.
Can I use HTML tags in pushes sent to Android?
Yes, in Android you may use the following HTML tags in order to modify the appearance of a push:
Place these HTML tags in the Message input field, and use them in the API request as well. Note that some Android devices may fail to process these HTML tags properly, but most of the devices we have used for tests displayed formatting properly.
How to set a notification icon in Android Lollipop (and later versions)?
In Android Lollipop icons were changed to be white only. Therefore, if you select targetSdkVersion >= 21 in your AndroidManifest.xml file, Android will only use alpha-channel of the icon. See more on the behavior in Android documentation.
The system ignores all non-alpha channels in action icons and in the main notification icon. Assume these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray. This is beyond Pushwoosh SDK control.
1. Create the notification icon according to the Android guidelines. As per documentation, the system will ignore all the colors.
1.1. Name the icon as pw_notification.png and put it in res/drawable folder. Pushwoosh SDK will use this icon as default for notifications.
1.2. Alternatively, you can use Remote API and set the "android_icon"
parameter value to the icon image (without file extension).
Using Pushwoosh SDK with other FCM services
You can use Pushwoosh alongside with other SDKs that use FCM for push messaging. To do that you should create a router service to distribute events between the services. First, add the pushwoosh-firebase dependency alongside the main Pushwoosh module:
Create the routing class:
Register the routers in your AndroidManifest.xml:
Using Pushwoosh with LeakCanary or AppMetrica libraries
When you integrate analytics tools such as LeakCanary, AppMetrica or others, these libraries start a new process, creating new instance of the app. Since you can't listen for the push notifications in another process, this results in java.lang.NullPointerException
being thrown.
If you call registerForPushNotifications
inside Application.onCreate()
, you should check if you are in the application's main process. Use the following code to perform this check:
Deleting particular received notifications from a device locally
If you want to remove a non-relevant push when performing a specific action inside your application, you can use the following approach:
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.
Last updated