question

omerkhalid avatar image
omerkhalid asked

Receiving push notification in ios

I am building a push notification module for my platform but I am a little confused about the difference between handling android push notifications and ios push notifications even though I have gone through the documentation.

I can see that there is a handler for receiving push notification in android in the tutorial doc https://docs.microsoft.com/en-us/gaming/playfab/features/engagement/push-notifications/push-notifications-for-android

However, I can't see how to handle notifications for ios. I don't want two separate implementations for ios and android. One implementation would be very helpful. Thanks

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.

JayZuo avatar image
JayZuo answered

I don't want two separate implementations for ios and android.

If you want to use PlayFab APIs to send push notifications, then I'm afraid you will have to separate the implementations for iOS and Android.

As you can see in Push notifications for Android & Push notifications for iOS, Android uses Firebase Cloud Messaging (FCM) to send Push Notification, while iOS uses Apple Push Notification Service (APNS). This also requires the client using different SDKs. For example, Unity Android project will need to add Firebase Unity SDKs, while Unity iOS project can use Unity Mobile Notifications package. If you can find a SDK that supports both FCM and APNS, then you may able to use one implementation for both iOS and Android.

If you are OK with not using existing PlayFab APIs, then one possible way might be using FCM to implement iOS Push Notification as discussed in https://community.playfab.com/comments/16798/view.html & https://community.playfab.com/comments/23959/view.html.

4 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.

omerkhalid avatar image omerkhalid commented ·

I will prefer sticking with PlayFab for now and do two separate implementations for that. However, I don't see any example of how to handle received notifications for ios. Can you share any thread or any other example for that?

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ omerkhalid commented ·
0 Likes 0 ·
omerkhalid avatar image omerkhalid commented ·

I also saw in Brendon's answer that we should be making two separate projects for ios and android with FCM implementation for android and unity mobile notifications for ios. Is this true or has there been any change in this? I initially thought by two implementations you meant two different classes or interface implementations in one project

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ omerkhalid commented ·

It would be better and easier to putting them in different projects.

0 Likes 0 ·
omerkhalid avatar image
omerkhalid answered

@Jay Zuo so we have decided to go with calling fcm send from cloudscript. We are using azure functions as cloudscript but I have a few questions

a) How do I register for push notifications for both ios and android for firebase using playfab api?

b) How do I call fcm send api from azure function for my game?

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.

JayZuo avatar image JayZuo ♦ commented ·

When using FCM for both iOS and Android Push Notification, you are not using PlayFab APIs anymore. Please follow Firebase docs here: Firebase Cloud Messaging (google.com).

As you are using Azure Functions as CloudScript, Azure Functions will be your server environment. You can use Firebase Admin SDK with Azure Function, authorize and build send requests as per Authorize send requests | Firebase (google.com) & Build app server send requests | Firebase (google.com).

If you still have questions about using FCM, I'd suggest seeking help from Firebase Support.

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.