Android FAQ


What does Android push token and hwid look like?
Android device push tokens can differ in length (usually below 255 characters), and start with APA… Push token example:

APA91bFoi3lMMre9G3XzR1LrF4ZT82_15MsMdEICogXSLB8-MrdkRuRQFwNI5u8Dh0cI90ABD3BOKnxkEla8cGdisbDHl5cVIkZah5QUhSAxzx4Roa7b4xy9tvx9iNSYw-eXBYYd8k1XKf8Q_Qq1X9-x-U-Y79vdPq
Using raw device tokens for targeting specific devices is not the most reliable way because *GCM push tokens tend to change from time to time*, and it’s hard to tell how often it occurs. Therefore, we strongly recommend using **Tags** to send pushes to specific devices. HWID example:
a9f282012f5dce9e
- - - - - -

How can I obtain my Android device push token?
You can obtain your Android device push token in the console log. You will need to use the logcat tool in Android Studio.

You should open the ddms.bat file located in C:\Users\%Username%\AppData\Local\Android\sdk\tools\ddms.bat, connect your device to the PC and allow USB debugging in the Android settings. Then run your application on the device. Locate the /registerDevice Pushwoosh call, and there you will see the push token for your device, which you can later use in Test Devices.

Android Studio Logcat

Please note that you can simply launch this file from its location without launching the Android Studio itself. - - - - - -

How to locate my Google Project Number?
The Project Number is automatically assigned by the Google Developers Console when you create a project. You can find the Project Number in the “Overview” tab of the Google API console.

Screen_Shot_2014-12-29_at_16_48_09

Here, 558498127919 is the Project Number you enter in the app. Don’t confuse it with Project ID, which is a completely different identifier & is used only within Google Developers Console! Even though GCM Project Number is a number, make sure you prefix it with the letter “A” when integrating the following Android SDKs into your project: Native, Unity, Marmalade, Adobe AIR and Xamarin.


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 the permission to access images, device contacts, etc.- - - - - -

How accurate is the total number of Android subscribers?
Pushwoosh clears unsubscribed Android devices from the database upon receiving the “NotRegistered” error from GCM, which may be returned after the second attempt to reach the specific device. It means that you have to send 2 pushes to the unsubscribed device to have it removed from our database.
Here’s the most common scenario described in the GCM documentation:

  1. Your subscriber uninstalls the app.
  2. Pushwoosh sends a message to GCM server.
  3. The GCM server sends the message to your user’s device.
  4. The GCM 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.
  5. The GCM client on the device informs the GCM server that the app was uninstalled.
  6. The GCM server marks the registration ID for deletion.
  7. Pushwoosh sends another message to GCM.
  8. The GCM returns a NotRegistered error message.
  9. Pushwoosh removes the push token from your userbase.

Note that it might take a while for the registration ID be completely removed from GCM. Thus it is possible that messages sent during 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:

​Hello world! Hello hi hey
These HTML tags should be placed in the Message input field, and they can be used in the API request as well. Please note that these HTML tags may not be processed properly by some Android devices, but most of devices that we used for tests displayed the formatting properly. - - - - - -
How to set notification icon in Android Lollipop?
In Android Lollipop icons were changed to be white only. Therefore, if you select **targetSdkVersion >= 21** in your AndroidManifest.xml Android will use alpha-channel of the icon only. See more on the behavior in [Android documentation](https://developer.android.com/about/versions/android-5.0-changes.html#BehaviorNotifications).

The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that 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.

However, you can revert this behavior to use old style colored icons:1. Set targetSdkVersion to 19. This automatically brings the old behavior back.

OR

2. Create the notification icon according to the Android guidelines. As per documentation, the system will ignore all the colors.
2.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.
2.2. Alternatively, you can use Remote API and set the "android_icon" parameter value to the icon image (without file extension).


Using Local Notifications with Pushwoosh
If you use Local Notifications update your AndroidManifest.xml with the following code inside the <application> tag:

...
- - - - - -

Using Custom Push Service in Android
If you need to handle custom notifications from your server, you should create a class extended from com.arellomobile.android.push.PushGCMIntentService, and include this custom intent service under the “PW_PUSH_SERVICE” tag in your manifest file.

Ex.: In your manifest you have to substitute the

with


Using Custom Push Broadcast Receiver in Android
If you need to programmatically select which activity to display as a result of push notification, you can create custom broadcast receiver to receive push notification tap event. You also have to add your receiver to AndroidManifest.xml. Then include fully qualified class name of the receiver in metadata under “PW_NOTIFICATION_RECEIVER” value.

Example of the receiver (note pre- and post-handling functions): public class NotificationReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { if (intent == null) return; //Let Pushwoosh SDK to pre-handling push (Pushwoosh track stats, opens rich pages, etc.). //It will return Bundle with a push notification data Bundle pushBundle = PushManager.preHandlePush(context, intent); if(pushBundle == null) return; //get push bundle as JSON object JSONObject dataObject = PushManager.bundleToJSON(pushBundle); //Get default launcher intent for clarity Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); launchIntent.addCategory("android.intent.category.LAUNCHER"); launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); //Put push notifications payload in Intent launchIntent.putExtras(pushBundle); launchIntent.putExtra(PushManager.PUSH_RECEIVE_EVENT, dataObject.toString()); //Start activity! context.startActivity(launchIntent); //Let Pushwoosh SDK post-handle push (track stats, etc.) PushManager.postHandlePush(context, intent); } }