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 /
  • API and SDK Questions /
avatar image
Question by brett · Nov 29, 2017 at 03:21 AM · unity3dPush Notifications

FCM ios push notifications aren't working (android does) for Unity

When first setting up Push Notifications, I started with Android.

I added the Google server API key to my title Settings section, created the project on the Firebase console, added an app for the google play id, and downloaded the google-services.json and added it to my Unity Assets folder.

I followed the instructions here for a client side c# script: https://firebase.google.com/docs/cloud-messaging/unity/client

I tested it, worked like a charm, no problems at all.

Next I wanted to set up ios... I created my .p12 certificate for the project / Mac Book I was using, then converted it to a .cen file using this: openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts

Right away the request for ios push notification request was returning an error in xcode telling me that my token I am passing in was too long, and couldn't go past a certain limit (I forget the exact error, but can bring it up if that will help).

So after doing some digging, I found this: https://api.playfab.com/docs/tutorials/landing-players/push-notification-basics/push-notifications-for-ios

It says to convert the byte array to a string... request.DeviceToken = System.BitConverter.ToString(token).Replace("-", "").ToLower();

Since I already had a string, but PlayFab wants it in a certain format, I attempted to first convert the token FCM gave me back to a byte array, then parse it the way PlayFab likes it:

pushToken = System.BitConverter.ToString(Encoding.ASCII.GetBytes(pushToken)).Replace("-", "").ToLower();

This seemed to have worked client side, I get the response that the end point was registered successfully, and when I look at my PlayFab dashboard, it shows an end point under my player. So I clicked to test sending the endpoint a push, and although it behaves as though the push was sent, I never received it on my client app.

I thought it was a glitch, so I try sending another push test, and this time it says I need to enter a number for 'Badge (number greater than zero)'. So I throw in some random int, like 1 or 2, etc.

This time the push fails, and it tells me the client unregistered the endpoint... even though I didn't touch the client app in any way, shape, or form.

At this point, I was advised by a friend not to use FCM, but just to follow the instructions here:

https://api.playfab.com/docs/tutorials/landing-players/push-notification-basics/push-notifications-for-ios

So I do, and I get the same results... the end point is registered, but when I try to sent a push test, the client never gets it, and the second attempt fails with the same error.

Then I get desperate, and think that I could just request pushes as an android, since I'm using a FCM token, PlayFab shouldn't care if the platform is ios or an apk, but this didn't work either.

So after double and triple checking all my work, I'm posting here to see if there is something I am missing, or if there is perhaps an issue on PlayFabs back end...

Android is still working like a charm.

Comment

People who like this

0 Show 1
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 brett · Nov 28, 2017 at 03:15 PM 0
Share

Also, I forgot to mention it above, but I created a second app in fcm console for ios, and downloaded my GoogleService-Info.plist and added it to the projects Assets folders. I was going to edit the initial post, but only saw a button to edit the title / tags.

4 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Nov 29, 2017 at 03:25 AM

Yes, we can't support using FCM on iOS currently, as that's not tested in our Push system. To see if this is due to the FCM setup attempt, can you try creating a new Title ID, setting it up for iOS specifically using the APNS or APNS_SANDBOX certificate info, and see if Push works on it in your game?

Comment

People who like this

0 Show 6 · 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 brett · Nov 29, 2017 at 05:48 PM 0
Share

I'll create a test project today and see what happens. Is there an eta for when PlayFab WILL support FCM for ios? It was super easy to install and set up, I think I just have to send you a token, and you need to accommodate the format / endpoint. I mean... isn't it almost identical to supporting it for Android?

If FCM is the problem, it's going to be a huge pain in the rear to clean out all the references to it from the project and xcode, I'm not even sure it would be possible (ios isn't my native dev platform).

I'm also skeptical to see how using FCM for Android, but NOT using it for ios is going to work, since it auto-installs so many things. I guess I'll find out when I build a new project from scratch. Perhaps if I just remove the ios app from my Firebase account it will help...

avatar image Brendan ♦♦ brett · Nov 29, 2017 at 06:19 PM 0
Share

I would expect it to be straightforward, but assuming so before reviewing the details would inevitably mean it's not. We don't have a date for support of FCM Push to iOS right now, but we've got a backlog item tracking it.

But I'm not referring to all references to FCM throughout your project - just the FCM Push to iOS. The rest shouldn't have any impact.

avatar image brett · Dec 02, 2017 at 02:49 AM 0
Share

I created a new project and had the same results.

I reached out to an associate, who has both ios and apk push notifications working through FCM for a title he's working on, and he showed me a way to handle them through a cloud script.

This bypasses the current PlayFab limitation, and has worked great. It took a little setup, but was worth it.

avatar image brett · Jan 10, 2018 at 10:46 PM 0
Share

I'm working on another contract, and having to implement push notifications for both Android and ios again. Has there been any progress testing FCM with ios in your push system?

Is there a solution? If I use FCM for Android, what is my choice for ios? As soon as I pull the repo on my mac book, and open unity, it auto installs all the FCM classes.

When is PlayFab going to get on board and support this? If you don't plan to support it, when can I expect a fix for the current situation?

Essentially, you're telling me if I want to use FCM for Android, I'm screwed for ios, and there's nothing you or I can do about it... I have yet to see a solution PlayFab has provided.

avatar image Brendan ♦♦ brett · Jan 12, 2018 at 11:37 PM 0
Share

The simple reality of it is that when you install FCM, it overrides the push receiver, and does not work with native iOS-formatted messages. If a) the FCM plugin could accept the native iOS Push format, or b) it gave you a way to have it in your project (for your Android SKU) without stealing the messages on the iOS SKU, there wouldn't be a problem. Unfortunately, we cannot change the way the FCM plugin behaves. And since our Push messages must use the native message format for each platform, that's not something we can easily work around.

For now, I would recommend either having two projects - one for iOS and one for Android, or else using https://fcm.googleapis.com/fcm/send in Cloud Script for your Push messages.

avatar image Jeff Posey Brendan ♦♦ · Nov 15, 2019 at 08:56 PM 1
Share

I am the latest to fall victim to this. I thought that PlayFab messaging through Firebase FCM was supposed to be a cross-platform solution.

The iOS client receives notifications I send using Firebase just fine, but not from PlayFab. The registration using the deviceToken byte array works fine and the PlayFabClientAPI.RegisterForIOSPushNotification call succeeds.

Is that function even useful if it's not working? Is it still used to register if you send notifications with cloud scripts?

Could you elaborate a bit on the suggested workarounds? Thanks.

"For now, I would recommend either having two projects - one for iOS and one for Android, or else using https://fcm.googleapis.com/fcm/send in Cloud Script for your Push messages."

avatar image

Answer by rob · Jul 26, 2019 at 10:09 PM

I have the exact same problem, two years later. I took exactly the same steps, tried to use Firebase at first, worked fine on Android. Then found I couldn't use the same token on iOS. So I followed the tutorial to set it up the recommended way and got rid of the Firebase stuff, removed the iOS app from Firebase console.

I'm now able to get a successful registration and am able to send push notifications with no errors but they never come through. Eventually it gives the error "iOS Push Notification Failed: Client has been unregistered for push notifications."

Tried deleting the player in PlayFab and starting with a new account, same problem.

Comment

People who like this

0 Show 1 · 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 FranklinChen · Jan 26, 2020 at 11:38 AM 0
Share

Hi @rob @dejarajs, may I ask what kind of APNS cert you are using? If you are using XCode to build test app and deploy on your device, if ensure you are using the SANDBOX cert. After that, if your app have been registered via didRegisterForRemoteNotificationsWithDeviceToken call, using the device token to register PlayFab iOS push notification via RegisterForIOSPushNotification, then you can send the test notification with a template in player overview page. Let me know your setting and environment if it's still not working.

avatar image

Answer by dejarajs · Jan 23, 2020 at 05:32 AM

any luck here? It looks like a lot of people having issues implementing push notifications for iOS. The notifications never reach the device.

Comment
Shivaprasad
omerkhalid

People who like this

2 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 Shivaprasad · Apr 24, 2020 at 06:02 PM

@Brendan Bump

Comment

People who like this

0 Show 1 · 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 Brendan ♦♦ · Apr 24, 2020 at 06:51 PM 0
Share

Nothing has changed from what's stated above. If we make any changes to support FCM, that would be reflected in our release notes, at a minimum (and there might be a blog post about it). If your question isn't FCM-specific, please open a new thread with the details, and our support team will be able to help you.

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

    Unity RemoteNotification userData empty where I expect CustomData 1 Answer

    Push Notifications On Unity with Firebase 1 Answer

    Is it acceptable to put AndroidPushID (and iOSPushID) in TitleData so it can be modified remotely? 2 Answers

    ProfileAPI SetProfileLanguage randomly returning NotAuthorized 1 Answer

    Socket bind failed: already in use (Unity HLAPI custom server) 1 Answer

    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