2

I want to navigate to a specific view controller after I pressed the push notification, how to do it in here with OneSignal Push notifications?

 _ = OneSignal(launchOptions: launchOptions, appId: "b2f7f966-d8cc-11e4-bed1-df8f05be55ba") { (message, additionalData, isActive) in
        NSLog("OneSignal Notification opened:\nMessage: %@", message)

if additionalData != nil {
   NSLog("additionalData: %@", additionalData)
   // Check for and read any custom values you added to the notification
   // This done with the "Additonal Data" section the dashbaord.
   // OR setting the 'data' field on our REST API.
    if let customKey = additionalData["newid"] as! Int {
        //The navigation to a view controller code should be goes here...
        //I've no idea how to do it, I've tried some ways from stackoverflow also didn't work for me
    }
}
}
jefferyleo
  • 630
  • 3
  • 17
  • 34
  • I believe this is general question about deep linking. Pl have look at [this](http://docs.urbanairship.com/topic-guides/ios-deep-linking.html) and [one more link](http://www.brianjcoleman.com/tutorial-deep-linking-in-swift/) – Raviprakash Jan 07 '16 at 04:49

2 Answers2

1

You can use a segue like jkasten proposes, or also:

let controller = self.storyboard!.instantiateViewControllerWithIdentifier("storyboardID") as! ClassOfYourView
self.presentViewController(controller, animated: true, completion: nil)

Either way you will still need to create a storyboardID.

BrotherZen
  • 101
  • 2
  • 5
0

There are a few ways to do this, one of them is to call this from your "newid" if statement.

self.performSegueWithIdentifier("GoToViewController", sender:self)

If the code above does not work I recommend trying a few other answers from Opening viewController programatically in swift

Community
  • 1
  • 1
jkasten
  • 3,899
  • 3
  • 32
  • 51