0
votes

I am having trouble getting Push Notifications to work in my Unity application on Android. I have followed the steps in the Parse documentation, including setting up the AndroidManifest.xml. The device registers an installation, which I can see on the dashboard. However, when using the dashboard to create a Push the delivery report always says "PPNS - OUTDATED DEVICE" for my tablet.

I followed the instructions for creating the AndroidManifest.xml file from here: https://www.parse.com/apps/quickstart#parse_push/unity/android/existing

Do I need to set the "GCMSenderId" value of the installation? The documentation was kind of ambiguous on that.

Here are the contents of my 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="true"
      android:normalScreens="true"
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true"/>

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <permission android:protectionLevel="signature"
      android:name="com.unity3d.player.permission.C2D_MESSAGE" />
  <uses-permission android:name="com.unity3d.player.permission.C2D_MESSAGE" />

  <application
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  android:icon="@drawable/app_icon"
      android:label="@string/app_name"
      android:debuggable="true"> <!-- SET TO FALSE FOR RELEASE BUILD -->
    <activity android:name="com.unity3d.player.UnityPlayerActivity"
              android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>

    <service android:name="com.parse.ParsePushService" />
    <receiver android:name="com.parse.ParsePushBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="com.unity3d.player" />
      </intent-filter>
    </receiver>
  </application>
</manifest>
1

1 Answers

0
votes

OK, so I've figured it out. I had a few things wrong with the manifest file, but the most important thing was changing the package name from the default of "com.unity3d.player". I had another test Unity app on the device using the same default package name, and I believe that because it was installed first it was intercepting the notifications.

Anyway, here is my AndroidManifest.xml file for anyone else having trouble with Parse Push using Unity3D and Android devices.

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourcompany.yourproductname"
    android:installLocation="preferExternal"
    android:versionCode="1"
    android:versionName="1.0">
  <supports-screens
      android:smallScreens="true"
      android:normalScreens="true"
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true"/>

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <permission android:protectionLevel="signature"
      android:name="com.yourcompany.yourproductname.permission.C2D_MESSAGE" />
  <uses-permission android:name="com.yourcompany.yourproductname.permission.C2D_MESSAGE" />

  <application
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  android:icon="@drawable/app_icon"
      android:label="@string/app_name"
      android:debuggable="true"> <!-- SET TO FALSE FOR RELEASE BUILD -->
    <activity android:name="com.unity3d.player.UnityPlayerActivity"
              android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>

    <service android:name="com.parse.ParsePushService" />
    <receiver android:name="com.parse.ParsePushBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="com.yourcompany.yourproductname" />
      </intent-filter>
    </receiver>
  </application>
</manifest>

Note that you would replace all instances of "com.yourcompany.yourproductname" with whatever package name you want to use.