Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • Bugs /
avatar image
Question by Shivaprasad · Apr 24, 2020 at 06:01 PM · unity3dPush Notifications

IOS Push-notification not working IOS but works on Android.

Hi , We were following these links to add push notification to our cross platform project (IOS and Android).
https://docs.microsoft.com/en-us/gaming/playfab/features/engagement/push-notifications/quickstart

and

https://docs.microsoft.com/en-us/gaming/playfab/features/engagement/push-notifications/push-notifications-for-ios

We were able to easily setup for Android it worked very well with FCM.

But when we built the project for IOS using Unity's Package for Push notification. (As FCM is not supported for IOS)
https://docs.unity3d.com/Packages/com.unity.mobile.notifications@1.2/manual/index.html

----------------------------------------------------------Side Note------------------------------------------------------------
We also use this plugin because UnityEngine.iOS.NotificationServices.deviceToken was always null even after 3 seconds after calling UnityEngine.iOS.NotificationServices.RegisterForNotifications.
And having no proper callback we thought was not reliable any way to poll for the deviceToken, while not knowing whether RegisterForNotification was successful or not.

----------------------------------------------------------End of Side Note----------------------------------------------------

Then we ran into problem mentioned here

https://community.playfab.com/questions/15918/fcm-ios-push-notifications-arent-working-android-d.html

After that we were able to remove Firebase Messaging while building to IOS platform, even then we are facing same problem mentioned in above link.

But note that we are able to get notification on IOS device, via some service like
https://www.apnstester.com/apns/

Which makes us believe this might be a bug with Cross-platform message routing (PlayFab via Amazon Simple Notification Service [SNS]). As mentioned in Quickstart.


Comment

People who like this

0 Show 9
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sarah Zhang · Apr 27, 2020 at 02:17 AM 0
Share

We will try to reproduce it.

avatar image Shivaprasad Sarah Zhang · Apr 27, 2020 at 03:58 PM 0
Share

Thank you, Let me know if you have any luck solving the issue.

avatar image Shivaprasad · Apr 29, 2020 at 07:40 AM 0
Share

Any Updates on this guys?

avatar image Shivaprasad · May 04, 2020 at 03:08 PM 0
Share

Any Update on this?

avatar image Shivaprasad · May 06, 2020 at 02:37 PM 0
Share

Was this reproduced?

avatar image Shivaprasad · May 07, 2020 at 07:24 AM 0
Share

Any update?!

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Shivaprasad · May 11, 2020 at 09:22 PM

Issue was cause by miss match in .pem file and singing certificate used.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Sarah Zhang · May 11, 2020 at 06:45 PM

We have followed this tutorial -- Push Notifications For iOS to test pushing notifications for iOS. It works fine, the alert message would pop up when the application starts. After users choose "allow to push notification", the application can go on. The Client API RegisterForIOSPushNotification and SendPushNotification both can work. We also test to use this sample with the Unity Mobile Notifications Plugin, it works fine too. You can try to refer to the following sample code.

using System.Collections;
using PlayFab;
using PlayFab.ClientModels;
using Unity.Notifications.iOS;
using UnityEngine;


public class TestNotification : MonoBehaviour
{
    void Start()
    {
        StartCoroutine(RequestAuthorization());
    }


    IEnumerator RequestAuthorization()
    {
        using (var req = new AuthorizationRequest(AuthorizationOption.Alert | AuthorizationOption.Badge, true))
        {
            while (!req.IsFinished)
            {
                yield return null;
            };


            string res = "\n RequestAuthorization: \n";
            res += "\n finished: " + req.IsFinished;
            res += "\n granted :  " + req.Granted;
            res += "\n error:  " + req.Error;
            res += "\n deviceToken:  " + req.DeviceToken;
            Debug.Log(res);


            PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest
            {
                CustomId = "[YourCustomId]",
                CreateAccount = true,
                TitleId = PlayFabSettings.TitleId


            }, OnLoginSuccess, OnPlayFabError);
        }


    }


    private void OnLoginSuccess(LoginResult obj)
    {
        byte[] token = UnityEngine.iOS.NotificationServices.deviceToken;
        if (token != null)
        {
            RegisterForIOSPushNotificationRequest request = new RegisterForIOSPushNotificationRequest();
            request.DeviceToken = System.BitConverter.ToString(token).Replace("-", "").ToLower();
            PlayFabClientAPI.RegisterForIOSPushNotification(request, (RegisterForIOSPushNotificationResult result) =>
            {
                Debug.Log("Push Registration Successful");
            }, OnPlayFabError);
        }
        else
        {
            Debug.Log("Push Token was null!");
        }
    }


    private void OnPlayFabError(PlayFabError error)
    {
        Debug.Log(error.GenerateErrorReport());
    }
}



For more advanced questions about Unity Notification Plugins, please navigate to the Unity forum for professional supports. For more information on how to send push notifications to a device and how to add push notification support to your app, see the Apple Developer website documentation.

Comment

People who like this

0 Show 3 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Shivaprasad · May 13, 2020 at 11:44 AM 0
Share

This should actually be not working...Because on the latest XCode / IOS (13.x.x) give token description instead of token it self, in following format.

{ length = 32, bytes = 0xd3d997af 967d1f43 b405374a 13394d2f ... 28f10282 14af515f }

Please let me know if you are getting the token properly on IOS 13, i might be able to remove preview package of unity notification.

Also on Unity 2017.16
UnityEngine.iOS.NotificationServices.deviceToken;
is not byte[] rather it is string.

Also in playfab version wise documentation if this is maintained , that will be greate.

avatar image Shivaprasad · May 13, 2020 at 12:58 PM 0
Share

Correction it was Unity 2019.3.0

avatar image Sarah Zhang Shivaprasad · May 13, 2020 at 04:06 PM 0
Share

The test environment is Unity 2019.3, the latest Xcode, iOS 10. Thanks for your sharing.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Receiving "PlatformApplication does not exist" when setting iOS Push Notifications 2 Answers

    [UNITY] Namespace errors on PlayFab when switching from iOS/Android to PC/Mac build 1 Answer

    I can't log in with Playfab Editor Extensions 2 Answers

    Using custom account recovery email template doesn't work 2 Answers

    "Authentication - Login With Google Account" docs and Unity SDK are missing the "AccessToken" variable 3 Answers

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges