Languages

Menu
Sites
Language
Managing app launch via push notifications

Hello, i am trying to manage the app launch via push notification on a Samsung Galaxy Watch Active 2. My intended effect would be: i launch an action=ALERT notification on the target device, the user see the notification, and if he taps "Open app" the app opens on a page depending on the appData field of the notification. I am following the procedure as described on https://developer.tizen.org/development/guides/.net-application/messaging/push, under the section "Receiving push notifications", but it's a bit unclear where should i get the request application control and check the reason for application launch. I tried doing it in the constructor of the first page, but the isGetted value is always false, even when i launch an action=LAUNCH notification. What would be the best way to address this issue? Thanks for you time!

Edited by: Tobia Apolloni on 04 Nov, 2019

Responses

9 Replies
Tizen .NET

Hi,
Regarding "getting the appcontrol request", you can check it in OnAppControlReceived(AppControlReceivedEventArgs)
The person in charge of Push API will check the behavior and guide you how to use it.
Thanks.

Tobia Apolloni

Thank you. I will wait this person's input for more details

Kamaljeet Chauhan

Hi,

To enable your application to use the push functionality , some prerequisites are required.

Given on the link : ~https://developer.tizen.org/development/guides/.net-application/messaging/push#security

I hope you have taken care of all the steps listed there. They are must to use the push service.

Tobia Apolloni

Yes, i did take care of that.

I receive push notifications on my devices, but i am asking for a way to start the app in different pages, depending on the notification tapped. Please refer to my first post for details

Kamaljeet Chauhan

Can you please elaborate more "but it's a bit unclear where should i get the request application control and check the reason for application launch." This line.

Kamaljeet Chauhan

Hello Mr. Tobia Apolloni,

I have tested with a SDK Sample app and action=LAUNCH, is working fine.

Sample app : https://github.com/Samsung/Tizen-CSharp-Samples

you can compare your code with the sample app and change it accordingly.
 

Tobia Apolloni

Thanks for the help, i will expand a little on what i need.

Following the official guide on how to manage the reception of push notifications, i found this snippet:

  1. public static Tizen.Applications.AppControl _appCtrl;
    public static Tizen.Applications.AppControl.ExtraDataCollection _extraDataSet;
    
    _appCtrl = new AppControl();
    _extraDataSet = _appCtrl.ExtraData;
  2. Determine the reason for the application launch. If the reason for the launch is a notification, retrieve the latest push message.
    string GettedValue = "";
    bool isGetted = _extraDataSet.TryGet("http://tizen.org/appcontrol/data/push/launch_type", out GettedValue);
    
    if (isGetted)
    {
        if (GettedValue == "notification")
            /// Add your code here for when push messages arrive
        else if (GettedValue == "registration_change")
            /// Add your code here for when registration state is changed
    }

but whenever i launch the app via tap on a notification, the value isGetted is always false. 

I put this code in the constructor of the first page loaded.

Thank you for the example page, could you be more specific on what example to check?

Kamaljeet Chauhan

Hello Mr. Tobia Apolloni,

once you download/clone the Sample app code : https://github.com/Samsung/Tizen-CSharp-Samples

check : Wearable/PushReceiver

This is a sample module to test the push application. you can compare your code with this module.

if you want to test this sample app on your device you can test from the command line :

curl -k --header "appID: 71452c356f535db8" --header "appSecret: 238D559EC03F9B9C9F07B3C238E15368" https://apnortheast.push.samsungosp.com:8090/spp/pns/api/push --header "Content-Type: application/json" -d "{\"regID\": \"040103d71938d8990ae7a0dbce919688784ed324b869d9e0064349bc8f832fdc35e81717e13f0b1b984ca556b67250118b2f\", \"requestID\": \"0000002\", \"message\":\"badgeOption=INCREASE&badgeNumber=1&action=ALERT&alertMessage=Hi\", \"appData\": \"{id:gfghg&passwd:4544}\"}"

 

please change AppID , appSecret and regID .

Tobia Apolloni

Hello Mr. Chauhan, i did some testing on the settings you suggested, but i am still in need of help.

At the current state of  my work, this happens:

1. I launch a notification with action=LAUNCH to my device

2. The app correctly starts

3. When i initialize my PushManager class, in the constructor, i try to determine the reason for the application launch, as suggested by https://developer.tizen.org/ko/development/guides/.net-application/messaging/push under the section "Receiving push notifications"

4. the value "isGetted" (you can see what i mean in my post of the 21th of november), is always false, so i cannot determine the reason

Am i doing something wrong in my procedures?

Thank you very much for your time.