Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make notification clicks on apple devices redirect to links?

I am successfully able to send APNs to apple devices. I have coded up my app in react native. When someone clicks on the notification, I want to redirect them to a deep link I have configured my app to recognise - ne://page/id via deep linking, I don't need help with that. How do I redirect a notification click to a link ?

I have tried everything from my end. I looked at the official documentation here - it saysn nothing about urls and redirection - https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification

Moreover, I have using the apn-node library to send notifications via my server. Their notification docs have no url option, just something called urlArgs.

like image 652
tsaebeht Avatar asked Sep 02 '19 20:09

tsaebeht


1 Answers

  • set URL in the payload object of node-apn like this:
notification.payload = {
  url: "https://www.google.com"
}
  • parse the URL from the userInfo object in didReceiveRemoteNotification delegate method of AppDelegate

  • Open the URL in an in-App WebView or Safari

like image 118
Shahrukh Alam Avatar answered Sep 28 '22 02:09

Shahrukh Alam