Open notification while app running

0 votes
Hello, I'm making game with many scenes (Splash, Menu, Game, ...), i want my game run different scene when open a notification. Ex:

Notification with message "menu" : run Splash -> Menu

Notification with message "game" : run Splash -> Game

...

I want it work in 3 case:

- Game was closed: because Splash scene is 1st to open so i using method "getLastPushMessage" at Splash scene to run next scene -> worked (tested).

- Game in background: seem method "onMessage" was called when game resume (after click notification), if that right i can run next scene in this method.

- Game running: i dont know how to detect user just click notification (i want my game receive push when running). Please help me solve it, thanks!
asked Aug 2, 2016 in Unity by copangtnc (45 points)

1 Answer

0 votes

Hi Copangtnc,

Greetings!!!!!!!

As your first Case is working fine,

For Second Case : You need to valiadte the message and need to switch the on second scene from First Scene using getLastMessage function.

Game Running : You need add same callback as added on Splash Scene If want to gets the Notification while Game is running, you can also use getLastPushMessage API as well to trigered the message.

If you don't want to show push message on Notificar Bar while Game Running you can use app42pushserviceV2.jar file, but for testing I will suggest you to use the app42pushservice.jar file.

Let me know if it helps.

Thanks

Vishnu Garg

answered Aug 2, 2016 by Vishnu Garg (674 points)
For 3rd case, i want detect when user "open notification" not "receive notification", and "onMessage" callback will be called when receive notification. Example i'm doing something in Menu scene and suddenly i receive notification then my game will run next scene instantly.
In that case you can maintain screen type variable in your script and add Time Gap before starting a Game based on that variable if its on Menu then can add tie Gap before starting a new Game.
can you explain more detail, i don't understand
As per your use Case when you on Menu Screen if you receive push message Game is started instantly, To add time between this you can maintain a flag or variable in your app and handle it based on your logic.
Like if you are Menu screen took time to start the game as you have game data nad if its on game screen instantly start the game.
i want transfer to next scene only when user click notification (app still running) not by time, i mean i need a callback when user click notification.
There is no way to detect Click on Notification , you can do validation of push message you have received
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...