Notification badge on Unity android

0 votes
Hi,
I use your plugin for push notifications in Unity for android devices. I've bind all the keys and the code needed and I got it to work ... I receive my push notification but, no badge appears on my app icon.
I can see the number of push notification sent from the dash board under a "i" in all notifications but no badge.

There is something I have to do to get it to work? Or maybe someone know an issue?
asked Jul 7, 2014 in App42PaaS & BPaaS by stephanie (10 points)

1 Answer

0 votes

Hi Staphanie,

Thanks for writing to us.

For push notification badges increment, you need to extend your message by badge increment as show below:

PushNotificationService pushNotificationService = App42API.BuildPushNotificationService (); // Initializing PushNotification Service.
string userName = "UserName";
string message= "{'message':'Hello! I am here','badge':'increment'}";
pushNotificationService.SendPushMessageToUser(userName,message, new UnityCallBack())

Kindly find the link which will contain the full details that how you can integrate the push notification badge process in your app.

Let me know if it helps.

Thanks.

answered Jul 8, 2014 by hs00105 (517 points)
Thanks for the answer,

But I still have a problems, maybe you'll be able to help me on that.
Actually, I don't want to send notifications from a device, I want to reach multiple devices by sending messages from the shephertz's Dashboard. So I can't handle the badges like that:
string message= "{'message':'Hello! I am here','badge':'increment'}";
All I have in the dashboard is a simple text box with no badge option and if I send a message like this previous one, the user receive the exact message, with the quotes and all ...

Also, the function "UpdatePushBadgeforUser" seems to be nonexistent.
Let me check with the sample plugin, i will let you know if there is something that you need to handle it. Also if you can share the details that in which version you are working on, it will help us?
I'm working with the  App42_Unity3D_SDK_1.9 and unity3D 4.3.4f1

and actually, I test on a Nexus 5 with android 4.4.4
Now I have notifications on both android and iOS platforms. I've noticed that when I sent something like "{'message':'Hello! I am here','badge':'increment'}" from the dashboard, it appears right on iOS and a badge appears but it keep all the quotes on Android and still don't make badge appears.

I still not have found a way to access pushNotificationService.UpdatePushBadgeforDevice ... I can handle it with something else but I don't know why I don't have this function if i'm supposed to.
Hey Staphanie,  Thanks for the reply.

Please download the latest SDK from the below link which will contain the "UpdatePushBadgeforDevice " method. https://github.com/shephertz/App42_Unity3D_SDK/archive/master.zip.

In case of Android the case is little bit different.

1. You can customize your Push Notification in Android .so we have reset Push Notification count when you call getLastMessage() function like :

    public void getLastMessage(){
         object[] googleProjectNo = new object[]{Constants.GoogleProjectNo};
        object[] unityParam = new object[]{Constants.CallBackMethod,this.gameObject.name,UnityRegistrationMethod};
          using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                playerActivityContext = actClass.GetStatic<AndroidJavaObject>("currentActivity");
             using (var pluginClass = new AndroidJavaClass("com.shephertz.app42.android.pushservice.App42PushService")) {
                if (pluginClass != null) {
                    testobj = pluginClass.CallStatic<AndroidJavaObject>("instance",playerActivityContext);
                    testobj.Call("getLastMessage");
                }
                }
            }
    }
2. If you want to reset by your own method you can resetCount function that will reset your Push Notification count by using :

public void resetCount(){
         object[] googleProjectNo = new object[]{Constants.GoogleProjectNo};
        object[] unityParam = new object[]{Constants.CallBackMethod,this.gameObject.name,UnityRegistrationMethod};
          using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                playerActivityContext = actClass.GetStatic<AndroidJavaObject>("currentActivity");
             using (var pluginClass = new AndroidJavaClass("com.shephertz.app42.android.pushservice.App42PushService")) {
                if (pluginClass != null) {
                    testobj = pluginClass.CallStatic<AndroidJavaObject>("instance",playerActivityContext);
                    testobj.Call("resetCount");
                }
                }
            }
    }

Please fell free to revert to us in case of any query is concern.

Thanks
Vishnu
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...