Rakesh
Rakesh

Reputation: 302

Deep Link in push notification navigating to App Store :- Problem with deep linking

I have a platform called net core which is an external source for sending push notification. The problem is that when I put the link in the notification and try to open the app by clicking the push notification. The link is not opening in the app, it is navigating to safari.

Is there a way to open the link in the app from push notification and open the specific view controller based on the data present in the link?

Guys any solution on this issue?

Thanks in advance

Upvotes: 1

Views: 1497

Answers (1)

Ilya Stukalov
Ilya Stukalov

Reputation: 101

Yes, it's possible

First of all, you should send URL correct way(in the data section of notification)

Then in

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

you need to get this URL from userInfo parameter(which is your notification)

Keep URL like this

var urlToOpen: String? 

in AppDelegate

Then in applicationDidBecomeActive method, you should check if urlToOpen is not nil and if not parse it as you wish and do anything you want(eg open specific ViewController or some other stuff).

p.s.

Don't forget to set urlToOpen to nil at the end of applicationDidBecomeActive method

Upvotes: 1

Related Questions