Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums
  1. Home
  2. APIs
  3. [Unity] Registering push notifications specifically for Async turns.

[Unity] Registering push notifications specifically for Async turns.

Scheduled Pinned Locked Moved Unsolved APIs
8 Posts 3 Posters 2.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    immortal.ray.dev
    wrote on last edited by
    #1

    My game only needs to send push notifications when the matched player has completed their turn in ASYNC match. I know the SubmitTurn function has an argument for push notification message. So how do I register just for this notification. The docs have information about sending our own push notifications which isn't needed for my game at the moment.
    Thanks in advance!

    1 Reply Last reply
    0
    • Paul WinterhalderP Offline
      Paul WinterhalderP Offline
      Paul Winterhalder
      brainCloudAdmin
      wrote on last edited by
      #2

      Hi @immortal-ray-dev,

      Is your game online or offline? If it's online - it's better to enable RTT - and then receive the events that are sent as players make their turns. You register for the generic event handler to receive those events.
      https://docs.braincloudservers.com/api/capi/rtt/registerrtteventcallback

      The Push Notification capability is used mostly for cosmetic push notifications - which have the advantage of causing the user to launch back into the app. The brainCloud client doesn't have a handler for those - you'd have to use the platform-specific (i.e. ios vs. android, etc.) to receive those messages.

      I hope this helps!

      Paul.

      I 1 Reply Last reply
      0
      • Paul WinterhalderP Paul Winterhalder

        Hi @immortal-ray-dev,

        Is your game online or offline? If it's online - it's better to enable RTT - and then receive the events that are sent as players make their turns. You register for the generic event handler to receive those events.
        https://docs.braincloudservers.com/api/capi/rtt/registerrtteventcallback

        The Push Notification capability is used mostly for cosmetic push notifications - which have the advantage of causing the user to launch back into the app. The brainCloud client doesn't have a handler for those - you'd have to use the platform-specific (i.e. ios vs. android, etc.) to receive those messages.

        I hope this helps!

        Paul.

        I Offline
        I Offline
        immortal.ray.dev
        wrote on last edited by immortal.ray.dev
        #3

        @Paul-Winterhalder The users can be offline. One user plays their turn and exits the game. After the opponent plays their turn, the offline user should receive push notification to launch the game and play their turn.

        RTT in enabled and works as expected. When both users are online, the match status is updated correctly. I need the push notification sent when the offline user has to play their turn. The docs were helpful but I'm a little lost on how to enable it so that the user receives a simple "Your opponent has played their turn. You turn now!" notification after the following code is called.

        AsyncMatchService.SubmitTurn(
                    currentMatch.ownerId,
                    currentMatch.matchId,
                    (ulong)currentMatch.version,
                    JsonWriter.Serialize(matchState),
                    "Your opponent has played their turn. You turn now!", // Push notif message
                    currentMatch.matchedProfile.ProfileId,
                    null,
                    null,
                    OnSubmitSuccess,
                    OnSubmitFailure
                );
        
        1 Reply Last reply
        0
        • Paul WinterhalderP Offline
          Paul WinterhalderP Offline
          Paul Winterhalder
          brainCloudAdmin
          wrote on last edited by
          #4

          Ah - okay - the process of setting your app for push notifications depends a lot on the platform. From a brainCloud API perspective - you need to register the push notification device token with brainCloud. That's done via this method:
          https://docs.braincloudservers.com/api/capi/pushnotification/registerpushnotificationdevicetoken

          But first - you need to set up push notification services for your app with the the iOS App Store or Google Play store. These tutorials will help:

          • iOS - https://docs.braincloudservers.com/learn/portal-tutorials/push-notification-configuration-ios/
          • Android - https://docs.braincloudservers.com/learn/portal-tutorials/push-notification-setup-firebase/

          I hope that helps!

          Paul.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            immortal.ray.dev
            wrote on last edited by immortal.ray.dev
            #5

            @Paul-Winterhalder Thank you. Just one question. What is the topic variable in Firebase docs in the link you sent?

            image.png

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JasonL
              bitHeads
              wrote on last edited by
              #6

              In the code, it's just a string variable, for the further concept of "topic", you can refer to this link -- https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

              image.png

              1 Reply Last reply
              0
              • Paul WinterhalderP Offline
                Paul WinterhalderP Offline
                Paul Winterhalder
                brainCloudAdmin
                wrote on last edited by
                #7

                Hi @immortal-ray-dev ,

                I think that line for subscribing to topics wouldn't be necessary to receive the brainCloud push notifications... we send them directly to the users via the device tokens. Try eliminating it...

                (We're checking on our end as well - will remove from the example if unnecessary).

                Paul.

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JasonL
                  bitHeads
                  wrote on last edited by
                  #8

                  For clarity, Firebase Cloud Messaging recommends creating a topic using Pub/Sub, though this approach is optional.

                  1 Reply Last reply
                  0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Solved
                  • Unsolved
                  • Users