question

felipeclaude avatar image
felipeclaude asked

Android manifest for Push Notifications

Good day!

I'm having trouble with android push notifications.

I've installed the playfab Android push plugin and had to modify the manifest because I have more than one android plugin in the project.

Every thing works fine:

1) Init OK (tokens and everything)

2) register for push OK

BUT I can only receive the push notification ingame.

Whenever I set PlayFabAndroidPlugin.UpdateRouting(true) (because I want to see it in the notification bar) I just don't get any message (not even in debug.logs).

Any help or ideas?

My modified manifest is as follows:

Kind regards!

<?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" />
  
  
  <permission android:name="com.unity3d.player.permission.C2D_MESSAGE" android:protectionLevel="signature" />
  <!-- //Change to your package name .permission.C2D_MESSAGE -->
  <uses-permission android:name="com.unity3d.player.permission.C2D_MESSAGE" />
  <!-- //Change to your package name .permission.C2D_MESSAGE -->
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="com.android.vending.BILLING" />
  <!-- Android GCM Plugin -->




  <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">


    <!-- Unity Activities -->
    <activity android:name="com.unity3d.player.UnityPlayerProxyActivity"
        android:launchMode="singleTask"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerActivity"
        android:launchMode="singleTask"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
        android:launchMode="singleTask"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <meta-data android:name="android.app.lib_name" android:value="unity" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
    <!-- End Unity Activities -->


    <!-- Begin GCM -->
    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <!-- for Gingerbread GSF backward compat -->
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="com.unity3d.player" />
        <!-- //Change to your package name -->
      </intent-filter>
    </receiver>


    <service android:name="com.playfab.unityplugin.GCM.PlayFabGcmListenerService" android:exported="false">
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
      </intent-filter>
    </service>


    <service
        android:name="com.playfab.unityplugin.GCM.PlayFabInstanceIDListenerService"
        android:exported="false">
      <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID"/>
      </intent-filter>
    </service>
    <service
        android:name="com.playfab.unityplugin.GCM.PlayFabRegistrationIntentService"
        android:exported="false">
    </service>
    <service
        android:name="com.playfab.unityplugin.PlayFabUnityAndroidPlugin"
        android:exported="false"
        android:stopWithTask="true">
    </service>


    <!--<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />-->


    <!-- End GCM -->


    <!-- Begin IAP -->


    <!-- End IAP -->
    <activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
    <activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
    <activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
    <activity android:name="com.facebook.unity.AppInviteDialogActivity" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb1234554429917577" />
    <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider1234554429917577" android:exported="true" />
  </application>
</manifest>
Push Notifications
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
@felipeclaude I responded to your ticket on your other issue about the null ref. Check your email for details about that.

As for this issue, you should not need to call UpdateRouting , our plugin auto-detects when Unity is running and sends the message via SendMessage to the "_PlayFabGO" game object.

UnityPlayer.UnitySendMessage(PlayFabUnityAndroidPlugin.UNITY_EVENT_OBJECT, "GCMMessageReceived", message);

As you can see here, a method GCMMessageReceived is called and handled by the script on the _PlayFabGO game object. This fires and event in Unity that you can subscribe to.


In addition, I noticed that this manifest suggest that your Playfab Android Plugin is out of date, so you should update to the latest plugin.

Also we have a sample project available, and I have tested this out today and it is working properly. When unity is open and has focus the notifications properly route in-game.

Hope this helps

1 comment
10 |1200

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

felipeclaude avatar image felipeclaude commented ·

I've just responded on the other ticket hahaha,

This manifest is no longer up to date (I've written the manifest up to date on the other ticket).

The first thing I did encountering this issue was to update to 5.0.

Please tell me in which ticket should we continue chatting.


Regards.

0 Likes 0 ·
Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Felipe,

I would like to point you to our Push Notification Debugger Project. This project should provide everything you need to test your setup.

Steps:

  1. Install the asset package into a new Unity project
  2. Open the Debugger.unity scene
  3. Select the PlayFabLoginManager and edit the following values:
    • PlayFabAutoLogin.cs >> Title Id: set to your title Id
    • ScreenOutput.cs >> GoogleProjectId: the project number associated and displayed all over your e google developer console
  4. Build the project to an android device
  5. After automatically logging in you should be able to click the Register button.
    • This should trigger an immediate response push notification that will be routed and displayed in-game
  6. The other button (Send Test Notification) requires the following Cloud Script method (below)
    • This step is not required but can be useful for testing more advanced push scenarios.
    • handlers.SendPushNote = function (args)

      {

      var request = {};

      request.Recipient = args.Id == undefined || args.Id == null ? currentPlayerId : args.Id;

      request.Message = args.Msg == undefined || args.Msg == null ? "" : args.Msg;

      request.Subject = args.Subject == undefined || args.Subject == null ? "" : args.Subject;

      server.SendPushNotification(request);

      }

  7. The last feature Route to Notification Bar, shows how you can optionally handle messages in the game client or just route them to the default android notification bar.


After you get the debugger up and running, it should be easy to back-out what is different between your client and this example.

Keep me posted with what you find.


-Zac

1 comment
10 |1200

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

felipeclaude avatar image felipeclaude commented ·

HI, I've Tried the debugger app, And it works.

But when I integrate it with the current project my above problems begin.

Wvery thing works fine just that when updateRouting is set to true nothing happens.

(the original post is with SendPushNote from cloudscript).

Once again with updaterouting to false I can see the push ingame.

But with it to true No notification is received.

I'm positive the problem is with the manifest since I have more than one android plugin installed.

regards!

0 Likes 0 ·
felipeclaude avatar image
felipeclaude answered

HI, I've Tried the debugger app, And it works.

But when I integrate it with the current project my above problems begin.

Wvery thing works fine just that when updateRouting is set to true nothing happens.

(the original post is with SendPushNote from cloudscript).

Once again with updaterouting to false I can see the push ingame.

But with it to true No notification is received.

I'm positive the problem is with the manifest since I have more than one android plugin installed.

regards!

10 |1200

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

felipeclaude avatar image
felipeclaude answered

Thanks for the response.

I've made just that!

In fact I'm sending the SendPushNote from cloudscript and receiving it OK ONLY if handled ingame.

Once I set UpdateRouting to true I don't receive anything.

The funny thing is that if I export the full debug project t works well. But When I integrate it into a project with more than one android plugin the notification bar pushes stop working and I only see ingame pushes from cloud script.

Regards!

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

@felipeclaude Have a look at this video that I made yesterday.

https://www.youtube.com/watch?v=ObdhM3Q9oaw&feature=youtu.be

It shows Push notifications being implemented from scratch. Towards the end of the video I show how to properly set the UpdateRouting()

I am using OnApplicationPause() & OnApplicationResume() to set the UpdateRouting(true) and UpdateRouting(false)

Are you sure this is being called in your code? I've tested this out and it works.

10 |1200

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

zephilwroxt avatar image
zephilwroxt answered

marco@playfab.com,

Thank you for the setting up video; but, the video freezes several times (1:57 - 7:39, 7:39 - 9:05, 9:05 - 20:16, 20:16 - 23:15, 23:19 - end of the video) and can't follow the setting, I tried using different browser and computers. Anyone here can watch the whole video without freezing?

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
@zephilwroxt

dang, looks like the video recording was bad. I'm not sure what happened. I'll have to re-record it. Stay tuned, I'll post back with a new video.

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.