question

Canberk Soner avatar image
Canberk Soner asked

Sending data messages

Can we send data messages instead of standard push notifications through FCM using PlayFab APIs?

I've only seen this api request so far:

https://api.playfab.com/documentation/server/method/SendPushNotification

And from what I've seen, it's a normal notification message, but what I need is a data message as described here:

https://firebase.google.com/docs/cloud-messaging/concept-options

What we're trying to achieve with this: When user X adds user Y as a friend, I want to display an ingame notification to user Y, showing an image in the UI, playing a sound if he's already in friend screen etc., but I don't want to display an actual push notification if the app is closed or in the background.

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.

1 Answer

·
JayZuo avatar image
JayZuo answered

With SendPushNotification method, you can not only send a data message as in PushNotificationPackage, Message is required. May I know why you don't want the player receive a push notification when someone add him as a friend. I'd think it's a good practice even when the app is closed or in the background.

If you do need this function, you can use https://fcm.googleapis.com/fcm/send in Cloud Script for your Push messages. For more info, please check firebase's documentation. And you may also look forward to the PubSub feature which is in private preview now and it might be more suitable for your scenario.

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

Canberk Soner avatar image Canberk Soner commented ·

"May I know why you don't want the player receive a push notification when someone add him as a friend. I'd think it's a good practice even when the app is closed or in the background."

Because friend notification is just one example of this case. We also need this sort of backend-to-client messaging for a few other features such as room announcements, clan related events etc.

I had another question here about this and I think the result was that PlayFab doesn't support that sort of one-way connection now.

0 Likes 0 ·
brendan avatar image brendan Canberk Soner commented ·

Right now, it's possible to use the AdvancedPlatformDelivery parameter to pass along a data package that you could process in a custom plugin that you write.

I suspect though, that what you really want is going to be our upcoming PubSub (https://blog.playfab.com/blog/upcoming-roadmap-2018-q4-oct-dec-edition) feature. We'll be updating the blog post for Q1 from earlier today to clarify the status on that.

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.