using version 11 and OneSignal API.

How to redirect to a URL when the push notification is clicked?


jesse1974 wrote:

using version 11 and OneSignal API.

How to redirect to a URL when the push notification is clicked?


I'm not sure I entirely understand your question, but assuming you are talking about a mobile app, here's what you need to do.

Add a dependency to the OneSignalPlugin interface block OneSignal and add this block to the layout of your mobile screen, e.g. at the end of the Common\Layout. The OneSignal block will not be visible to the user.

The OneSignal block has 2 events, OnNotificationOpenend and OnNotificationReceived. You can create client actions as handlers for these two events under the Common\Layout block (if you insert the OneSignal block there). In the OnNotificationOpened handler you can add code to open a URL.


Thank you for your response, and sorry for the confusion. My question pertains to the OneSignalApi DeepLink parameter when you send using API. My understanding is that you can pass a DeepLink parameter to send push notification API and it can open the application and display the target screen.

It is possible also to redirect it to an external URL instead? as stated in the OneSignal documentation here.


Regarding the solution that you've mentioned, is it possible to pass the target url from the notification sent? 


TIA


Solution

Hi. To send a OneSignal notification deeplink , you'll need to do something like this 


where Scheme should be your application Id lower case (com.outsystemscloud.mypersonal.mymobileapp), Application is the module your screen is (MyApp) and TargetScreen is your screen name (Homescreen). If you have input parameters ,  you have to map them into the Parameters .


After all is said and done, once you open a notification, your OneSignal webblock is going to return you com.outsystemscloud.mypersonal.mymobileapp://MyApp/Homescreen that you can use to navigate using ExternalUrl navigation.


About external URL, like www.google.com for example, looking into the OneSignal extension, it seems to be possible. However, I wouldn't be surprise if you had to customize the extension as I had to customize it as it doesn't support notifications with Title (the bold part of the notification), it only sends notifications with subtitle

Solution

jesse1974 wrote:

Thank you for your response, and sorry for the confusion. My question pertains to the OneSignalApi DeepLink parameter when you send using API. My understanding is that you can pass a DeepLink parameter to send push notification API and it can open the application and display the target screen.

It is possible also to redirect it to an external URL instead? as stated in the OneSignal documentation here.


Regarding the solution that you've mentioned, is it possible to pass the target url from the notification sent? 


TIA


You can direct to a specific screen by passing a PushNotificationDeeplink variable (which is  a structure of the OneSignalAPI) with the OneSignal SendPushNotificationToXXX action. Just create a local variable with that data type and set these values:

Scheme: the app identifier used to generate the mobile app followed by '://'; for example, if your app identifier is 'com.mycompany.myapp', Scheme should be set to "com.mycompany.myapp://"

Application: the name of your mobile application MODULE in Outsystems, for example, if your mobile application is called "My Mobile App" and the module within that application is called "MyApp", Application should be set to "MyApp"

TargetScreen: the name of the screen you want to open, which is the exact name of the screen in your module.

If the screen has input parameters you can specify those in the Parameters list, where you need to set Key to the exact name of the parameter and Value to the value you want to pass.


As for passing an external URL, I do not have any experience with that, sorry.


Good luck!


Thank you, Frans and Gab, for your helpful suggestions. I really appreciate the effort. This is enough information for me to figure out what I'm trying to accomplish.