question

cernji avatar image
cernji asked

Android Push Token not available

Howdy,

I've followed the guide for setting up push notifications on Android and have been able to run the (outdated) example project, but am having trouble configuring push notifications with the updated plugin.

Getting the following after logging in

06-18 01:48:02.089 16252 16303 I Unity   : Login result: 5075BE13DA90CA6B
06-18 01:48:02.089 16252 16303 I Unity   :
06-18 01:48:02.089 16252 16303 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
06-18 01:48:02.089 16252 16303 I Unity   :
06-18 01:48:02.091 16252 16303 I Unity   : PlayFab GCM MESSAGE: You must log in before calling TriggerManualRegistration()
06-18 01:48:02.091 16252 16303 I Unity   : Android Push Token not available
06-18 01:48:02.091 16252 16303 I Unity   :
06-18 01:48:02.091 16252 16303 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
06-18 01:48:02.091 16252 16303 I Unity   :

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.

1807605288 avatar image
1807605288 answered

I suspect that you have not updated your SenderId to match your Firebase Sender ID described in this document:
https://api.playfab.com/docs/tutorials/landing-players/push-notification-basics/push-notifications-for-android

I took your titleID and SenderID and loaded it into my test app:

https://github.com/PlayFab/UnicornBattle/tree/master/UnicornPush

and it worked perfectly.

Please double check your SenderID is yours, and not ours. 185761034633 is ours, and it won't work with your title. Yours starts and ends with a 3.

7 comments
10 |1200

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

1807605288 avatar image 1807605288 ♦ commented ·

For posterity, SenderIDs are not "secure" information, as they are published unencrypted on your client. However, I have avoided posting cernji's here for privacy.

0 Likes 0 ·
cernji avatar image cernji 1807605288 ♦ commented ·

Thanks for checking for me, but following the steps under SenderID: in the guide and 185761034633 is the ID that I see in my Firebase and GCM consoles.

How are you finding a SenderID starting and ending with 3?

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ 1807605288 ♦ commented ·

Can you get on our PlayFab-community slack channel, and contact me directly (pgilmore)?

It's probably best if we have faster, and more secure communication to resolve this.

Short answer for everybody else: If your registered credentials in PlayFab don't match your Firebase information, then it won't work. :D

0 Likes 0 ·
cernji avatar image cernji 1807605288 ♦ commented ·

Sure can. Whats the address?

0 Likes 0 ·
Show more comments
brendan avatar image
brendan answered

That error (the PlayFab GCM error) would indicate that the user isn't signed in yet, which seems odd, since it looks like you're logging a PlayFab ID earlier in the flow. Still, it's hard to say without a more detailed log. Can you tell us the Title ID and provide the code snippets showing login and the call to register for Push?

10 |1200

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

cernji avatar image
cernji answered

Sure thing. The titleID is 1036 and I am just using the code from the Android push guide.

Also, it seems that _myPushToken is not being populated and/or LoadPlugin in PlayFabAndroidPushPlugin is not being called when run on the device

using PlayFab;
using PlayFab.Android;
using PlayFab.ClientModels;
using UnityEngine;
using System.Collections;


public class UniPushScript : MonoBehaviour
{
    // YOU MUST REPLACE THESE VALUES WITH YOUR TITLE AND YOUR SENDER
    // This is an existing PlayFab title, which is already set up, but you should not use it for more than a single test notification
    private const string TITLE_ID = "1036"; // TODO: Use your own titleId
    private const string ANDROID_PUSH_SENDER_ID = "185761034633"; // TODO: Use your own FCM SenderId


    private void Start()
    {
        PlayFabSettings.TitleId = TITLE_ID;
        PlayFabAndroidPushPlugin.Setup(ANDROID_PUSH_SENDER_ID);
        PlayFabAndroidPushPlugin.SendConfirmationMessage = true; //  OPTIONAL: This sends a confirmation message when you register
        PlayFabAndroidPushPlugin.ConfirmationMessage = "Push notifications registered successfully"; //  OPTIONAL: This sends a confirmation message when you register


        StartLoginSequence();
    }


    private static void OnSharedFailure(PlayFabError error)
    {
        Debug.LogError(error.GenerateErrorReport());
    }


    void StartLoginSequence()
    {
        var loginRequest = new LoginWithCustomIDRequest
        {
            CustomId = SystemInfo.deviceUniqueIdentifier,
            CreateAccount = true,
        };
        PlayFabClientAPI.LoginWithCustomID(loginRequest, OnLoginSuccess, OnSharedFailure);
    }
    void OnLoginSuccess(LoginResult result)
    {
        Debug.Log("Login result: " + result.PlayFabId);
        Register();
    }
    void Register()
    {
        PlayFabAndroidPushPlugin.TriggerManualRegistration();
    }
}
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.

cernji avatar image cernji commented ·

Further to this @Brendan, I have deleted all Google .aar's and reimported the full PlayFab plugin and the Push plugin. No change.

The script above was used in an empty scene to isolate the error from the rest of the game.

0 Likes 0 ·

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.