Unity Android Push error "[ errorCode=InvalidRegistration ]"

0 votes

I'm trying to setup push notification for Unity game on Android, I got the GCM server key added to app42 dashboard, I'm using latest app42 sdk - 4.1.2, I've intergated it as per instructions, I can see the device in the dashboard, but when trying to send push to it I receieve an error and the push is not delivered:

[ errorCode=InvalidRegistration ]

 

Here's my Unity manifest file (project id is replaced in the actual manifest):

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
  <supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <permission android:name="com.lephco.killdead.permission.C2D_MESSAGE" android:protectionLevel="signature" />
  <uses-sdk android:minSdkVersion="16" />
  <application android:theme="@android:style/Theme.NoTitleBar" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:hardwareAccelerated="true">
    <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ <projectid>" />
    <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ <projectid>" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <receiver android:name="com.androidnative.gcm.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" android:exported="true">
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="com.lephco.killdead" />
      </intent-filter>
    </receiver>
    <intent-filter>
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
      <category android:name="com.lephco.killdead" />
    </intent-filter>
    <receiver android:name="com.androidnative.features.notifications.LocalNotificationReceiver" />
    <service android:name="com.androidnative.gcm.GcmIntentService" />
    <service android:name="com.shephertz.app42.push.plugin.App42GCMService" />
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name="com.androidnative.AndroidNativeProxy" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <activity android:name="com.androidnative.features.social.common.SocialProxyActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar">
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="oauth" android:host="com.lephco.killdead" />
      </intent-filter>
    </activity>

    <activity android:name="com.androidnative.billing.core.AN_BillingProxyActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <activity android:name="com.androidnative.gms.core.GooglePlaySupportActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
    <activity android:name="com.jirbo.adcolony.AdColonyOverlay" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.jirbo.adcolony.AdColonyFullscreen" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
    <activity android:name="com.jirbo.adcolony.AdColonyBrowser" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
  </application>
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="com.android.vending.BILLING" />
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.GET_TASKS" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="com.android.vending.CHECK_LICENSE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="com.lephco.killdead.permission.C2D_MESSAGE" />
</manifest>

 

asked Jan 12, 2016 in App42 Cloud API-BaaS by milosz.lewko (10 points)

1 Answer

0 votes

Hi Milosz,

Error Code InvalidRegistration is sent by Google when device Token is not valid.

Would you share, how your are registering device on GCM as generated Device Token is not valid one.

After going through with AndroidManifest.xml file I found different package name  or Bundle Identifier.

package="com.unity3d.player" Please change it with your package Name com.lephco.killdead

 

For GCM Error code, You can refer GCM Documentation.

 

Let me know the details.

 

Thanks

Vishnu Garg

 

answered Jan 13, 2016 by Vishnu Garg (674 points)
This is how I initialize app42 push api:

  App42Log.SetDebug(true);
        App42API.Initialize("key1",
            "key2");
        PushNotificationService pushNotificationService = App42API.BuildPushNotificationService();
        
        pushNotificationService.StoreDeviceToken(SystemInfo.deviceModel, SystemInfo.deviceUniqueIdentifier,
            com.shephertz.app42.paas.sdk.csharp.pushNotification.DeviceType.ANDROID, new UnityCallBack());

Documentation isn't really clear on how to use push notification API, how do I get the proper device token?
Actually you are storing deviceID on AppHQ that is not the one provided by GCM thats why you are getting InvalidRegistration error.

You can go through with the sample on Git-Hub
https://github.com/shephertz/App42_Push_Sample_Unity

Follow all the steps mentioned in ReadME file.

Let me know if you have any problem with integration.
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
...