Replacing playfab and azure with unity gaming services question

I’m just learning about Unity Game Services (UGS) so forgive me if I butcher the terminology.

I’m currently developing an asynchronous turn based game. At the moment, I’m using playfab as a baas with azure functions. I’m also using azure webpubsub and websockets for messaging. Lastly, I’m using playfab for the push notifications along with the Unity mobile package.

I’d like to simplify so I’m only using Unity and UGS if possible (i.e. move my azure function code to unity Cloud Code). From what I can tell, UGS has most of what I need but I’d like to clarify a couple of use cases.

The general flow of the app is user authenticates via playfab, gets pubsub connection via playfab api azure function call and connects to pubsub hub. Most calls then go through the pubsub where the ‘backend’ handles them and calls the playfab api if needed. The pubsub is basically acting as a relay server, as currently most of the game logic is on the client (which will change eventually).

Here are the clarifications I need:

Push notifications -

When a player in a multiplayer game makes a move, a message is sent via pub sub to the backend, the backend logs the move, updates the shared data on playfab, and sends a push notification via playfab api to the opponent letting them know a move has been made.

I know you can do push notification campaigns via the Unity Cloud Dashboard, but can I send push notifications for various events via cloud code as described above?

Player messaging -

Currently, players can only message each other if they have an active game and only while in the active game screen. The client sends a message to the backend via pubsub hub, which then sends the message to the opponent if they are in an active game.

I saw there is friend list and friend messaging, which is great, but can I also set up something similar to what I have using only UGS without the need for a multiplay game server or azure pubsub? I.e. Non-friend players can message each other if they are in an active game? I suppose a workaround could be to make the messaging part of the game data?

Lastly, from what I gather, this seems to be the scenario I would setup.

I would move my game logic from azure to Cloud Code (via custom module?). Player data and match data will be saved on Cloud Save.

Player authenticates with UGS via client. Client can then call the various functions in Cloud Code via the UGS api, which can then access data on Cloud Save.

More specifically, player 1 challenges player 2 to an async match via call to Cloud Code which notifies player 2 they have been challenged (in game if active, or via push notification if not).

Player 2 accepts challenge, player 1 receives push notification of acceptance, cloud code logic initializes game data and saves it to cloud save.

Player 1 makes move, which calls cloud code with updated state, cloud logic verifies and saves updated state to cloud save, sends notification and updated game state to player 2.

Also, even though player 1 and player 2 are not friends, they can message each other (via the client in game screen only)

And on and on.

Does this all seem doable with the current state of UGS?

If there are any specific tutorials for these scenarios, the links would be much appreciated.

Hi, we have a chess sample here is pretty similar to what you described.

For the messaging, you could use push notifications (similar to how they’re used in the sample to send moves). If you want the messages to work asynchronously you’d need to store them in Cloud Save also.

Thank you, I’ll take a look and update if I have any more questions

So I figured out how to convert most things and I’m liking it so far. However, I can’t seem to figure out how to get remote mobile notifications working the way I want.

In my game, when an opponent moves, the “server” sends a remote push notification (via playfab) to the players device, which they receive even if the app is not running. With UGS, the only remote push notification I’ve been able to get working is the test one from the Dashboard->push notifications.

They work, and they show when the app is not running, but they are very limited. Can I send those type of notifications from cloudcode at will? Am I going to have to use some third party solution again? Since the dashboard sends the type of notification I want using the pushToken obtained during registration, I feel I’m just missing something simple.