Hi, I am facing a problem in Push Notification in Android using Unity3d.

+3 votes
I followed the steps which are given here http://api.shephertz.com/tutorial/Push-Notification-Unity-Android/?index=pn-unity_android  


I am not getting the 7th point of the "Start Building" points. Where do I need to change the gameobject name?
asked Apr 21, 2014 in App42 Cloud API-BaaS by parth.joshi (31 points)

1 Answer

+1 vote
Best answer

We have updated our Sample So you have no need to specify Game object in our current Sample,It takes the default name (Main Camera) as a Push Title. if You want to change this you can change accordingly.So we have specify it in our previous version.

You can check Pushsample.cs file.

public void RegisterForPush(){
         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);


answered Apr 22, 2014 by Vishnu Garg (674 points)
selected Apr 23, 2014 by parth.joshi
Hi Vishnu,

Thank you for the reply.

The problem I am facing now is after running the project in Android device, The user is not getting registered/subscribed.

Please check the changes I made in the Constants.cs file.
Api Key & Secret Key  -  Here I put my Apps API key and Secret Key
GoogleProjectNo - Here I put my Google Developer Console's "Project ID"
UserId - Here I put my own name

I did not make any change to CallBackMethod and DeviceType strings, which are "Success" and "Android" respectively.

Do I need to make any other chances? What is going wrong in the changes I made?

Thanks in advance.
You have attached PushSample.cs on MainCamera and UI is showing on your device right?
Your device is configured with your google account?
Yes my device is configured with my google account. and Yes UI is showing on my device. I am typing random thing in the second smaller textField and then I am pressing "Send Push To All" button. And then I am getting this text in the first bigger one textField.

"com.shephertz.app43.pass.sdk.csharp.App43SecurityException: {"httpErrorCode":"401","appErrorCode":"1401","message":"UnAuthorized Access","details":"Client is not authorized"}
Hey Parth, I just want to confirm few things first.
1. Have you pass API key and Secret Key from AppHQ console on which you have created app?
2. com.shephertz.app43.pass.sdk.csharp.App43SecurityException:  is this exception is correct or its app42 not app42
Hi Vishnu,

Yes I have passed the API Key and Secret Key from AppHQ console. I got the keys from AppHQ Menu--> App Manager --> Application Keys .and here selecting my app from the "Services" drop down. I have passed the keys in Constants.cs file in the appropriate strings.

And the exact exception is this. It is app42,not app43. Sorry!

"com.shephertz.app42.paas.sdk.csharp.App42SecurityException: {"httpErrorCode":"401", "appErrorCode":"1401", "message":"UnAuthorized Access", "details":"Client is not authorized"}"
This exception occurs when:
1. Wrong API key and secret key
2. Device time is not correct (So can you check your device time)
Hi Vishnu,

I tried making a new app for the push notification. And now in that App I am getting this exception

"com.shephertz.app42.pass.sdk.csharp.App42Exception:  {"httpErrorCode":"404", "appErrorCode":"1706","message"."NOT FOUND"."details"."No device is registered with this App"}"

Do I need to register my device anywhere? What am I doing wrong now?

While making a new app I selected ACL to false. Is it creating any problem?
Hey Parth, This is ok, because no device is registered with you app so this exception is comes from server.
Now you can do :
1. Open App again.
2. Go to AppHQ console in PushNotification and select users of your app.
3. So if User registered  than you can found it here.
4. Hope you already submit your GCM server key in your app and same in sample.

Can you please share your contact detail so that we can make it easy for you in case of further query is concern
Hey Vishnu,

User is not getting registered. I can not see any of the user there.

Yes I have submitted GSM server key in my app on the AppHQ console which I can see in "Android Settings" options as "Push Key" i.e ServerKey and "Provider" i.e GSM  . And I have passed "Project Number" i.e 12 digit numeric number in "GoogleProjectNo" string in the Constants.cs file.

My email id is parth.joshi@credencys.com
Please help me!
For others who may be searching for this same issue, it appears you MUST pass a callback reference as the fourth parameter to StoreDeviceToken() despite the fact the docs say only the first three parameters are required.  You won't get a compile error with only the first three parameters, but the call will fail, and fail silently (no log output indicating failure).  It just won't succeed in registering your device/user.
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