question

Falcon Land avatar image
Falcon Land asked

Android Push Notifications. Need help.

Hi, 

we are trying to get Android Push notifications working with Playfab. So far I think we have everything setup correctly.  However when I try to send push notification for the user ( either using Cloudscript or via your web API) I got this response:

{
 "code": 200,
 "status": "OK",
 "data": {},
 "CallBackTimeMS": 1172
}

So it looks like the the notification made it through. However the notification will not show on the player phone and also as you can see the "data" field is empty. Therefore I can detect that the push notification acualy arrived on the phone but the notification itself is NULL. I could not find out what should I be doing wrong. We have everything setup correctly I guess. 

All of this is "check" for us:

1. You've registered using SetupPushNotification for GCM - YES

2. The player account has enabled Push Notifications using  AndroidDevicePushNotificationRegistration  -YES

3. You've checked that the platform token set up in your title's Settings is correct -YES

4. You've confirmed that notifications are enabled (not blocked) on the device - YES

5. You've confirmed that the application is installed on the device - YES

6. You're receiving a success response (200) to the SendPushNotification call -YES

Does anything come to your mind why we could not get this working?

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Flekoun,

First of all what SDK is your game being built with? If you are using Unity, you should be able to use our sample as a good testing application; just follow the PushCrashCoruse.docx. Next, I would like to know if you are using our GCM Unity plugin. If so, then run your Android build while hooked into the logcat debugging tool. You will see all GCM information (successes and errors) output to the console.   

Also, can you post the code where you are using SendPushNotification? 

Hope that helps,

Zac

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

marcowilliamspf avatar image
marcowilliamspf answered

Hey Flekoun, 

Are you sure you registered your device with the PlayFab API call? 

PlayFabClientAPI.AndroidDevicePushNotificationRegistration

Without this,  the server won't know the DeviceId of the user and the Push notification won't be turned on for the user.
You can verify that push is turned on under the players profile in the Game Manager


If Push Enabled is False, then you have not Registered the Device and no push notification will go to the device.

 I see that you said you did register it, but you might want to make sure that it was successful and check in Game Manager to make sure push is enabled.

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Falcon Land avatar image
Falcon Land answered

Hi, we use Unity. I tried your sample briefly but run into the exception errors when run on device, but had no time to study it more closely, so I will try later to make it work. We are using Voxel Busters Ultimate Native Plugins form Unity Asset store for notifications.

Here is the code for sending push notification :

public void SendPushNotification(string playfabID, string message, string subject) {

RunCloudScriptRequest request = new RunCloudScriptRequest ();
        
request.ActionId = "SendPushNotification";
             
request.ParamsEncoded =   "{\"PlayfabID\":\""+ playfabID + "\",\"Message\":\""+ message + "\",\"Subject\":\"" + subject + "\"}";
        
PlayFabClientAPI.RunCloudScript (request, SendPushNotificationCallback,OnPlayFabError);    

}

and the cloud script it is calling is :

handlers.SendPushNotification = function(args)
{
	
	server.SendPushNotification(
	{  
	  Recipient : args.PlayfabID,
	  Message : args.Message,
	  Subject :  args.Subject
	
 	 });
 	 
	return {};
}

Thanks a lot for your help guys, your support is great! Meanwhile I will try to get your sample code for push notifications working.

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Falcon Land avatar image
Falcon Land answered

@Marco

Yes the player I am trying to send push notification has Push Enabled. We are calling  

PlayFabClientAPI.AndroidDevicePushNotificationRegistration

Keep in mind that the notification indeed arrive for the player but the "Data" portion is empty and the notification itself is NULL, so no message,subject, anything is retrievable. Maybe it has something to do with the push notification plugin we use in unity to catch event of incoming push notification?

Jan

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

marcowilliamspf avatar image
marcowilliamspf answered

Well I can see how this could be problematic. If you are using  "Voxel Busters Ultimate Native Plugins"  there is most likely a conflict where you are using their plugin to deliver the Notification to the device.
If you look at this class in our Plugin:
http://ow.ly/WcS7L
You will notice the following code:
String message = "";
//Check for message first, if this message was sent via GCM API then it will contain "message"
//otherwise it might have been sent via AWS Simple Notification Service, in which the message is in the default key.
if(data.containsKey("message")){
message = data.getString("message");
} else if(data.containsKey("default")) {
message = data.getString("default");
}
So what is likely happening is that  Voxel is trying to handle the Push Notification ( which we sent via AWS Simple Notification Service ) and Voxel is looking for the message in the "message" key,  but that is not where it will exist.  it will look for it in the "default" key.
In order to get this to work,  Voxel needs to update to support AWS Simple Notification Service, or you will need to disable thier push notification handling and rely on our plugin to do the work for you.
Here is more information on our Plugin:
https://github.com/PlayFab/UnitySDK/tree/master/UnityAndroidPluginSource
With our plugin you can send "Rich" push messages with lots of other data related to the push notification.
Example:
{
"Title": "Message from Game",
"Icon": "app_icon",
"Message": "You've gained gold!",
"CustomData": {
"gold":"5",
"currency":"G"
}
}
Hope this info helps.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Falcon Land avatar image
Falcon Land answered

I am getting : 

AndroidJavaException: java.lang.ClassNotFoundException: com.playfab.unityplugin.PlayFabUnityAndroidPlugin

On the device each time I try to call PlayFabAndroidPlugin.Init();

I have PlayFabUnityAndroid.jar and manifest file in my Plugins/Android folder. I cannot find what files from the Git should I copy and where into the Unity project. Readme only refers to usage of functions in Unity. Can you help me?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.