'Redirect to app content from push notifications
Im looking to use branch.io to redirect users to a specific viewcontroller when remote push notification is tapped. It looks like I can create a deep link programmatically and add it to aps payload. However, payloads are created from the backend... Can't the backend just add relevant information in payload, so when didRecieveRemoteNotification is triggered I can read info and show correct view? What am I missing? What does branch do to enable these redirects that I cant do manually with the approach I explained?
Solution 1:[1]
You can definitely implement redirects manually without branch.io. I would suggest you to define some enum with all types of possible redirections. Because you can have the same redirections from different sources (push notifications, universal links).
For using PushNotifications you need to receive proper payloads from backend and parse it on the client. You can define initializers for different sources.
I can recommend you to have a look at the Kickstarter implementation for handling redirects. No 3rd party libs are required!
enum NavigationRoute {
case like(userID: Int)
case friendBirthday(friendId: Int)
// MARK: - Initializers
init?(notificationPayload: Any) {
//
}
init?(universalLinkContent: Any) {
//
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eugene El |
