Controlling which view controller loads after receiving a push notification in SWIFT

Updated for Swift 4.2 Like it was said, you want to register to remote notifications in applicationDidLaunchWithOptions : func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let pushSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) UIApplication.shared.registerUserNotificationSettings(pushSettings) UIApplication.shared.registerForRemoteNotifications() } There is no way to know in which viewController you will be when you … Read more

what kind of certificate do I need to test apns using ad-hoc distribution?

You need to create a Distribution Certificate. The Distribution Certificate are used for creating Distribution Provisioning Profiles. Which will allow you to do the following: Create an Ad-Hoc version of your app (this is used if you want to distribute to beta-users, testers, etc (this is what you want)) Create an App Store version of … Read more

Does iOS 13 has new way of getting device notification token?

You may use this method to fetch the device token on iOS 13 onwards: Objective-C: + (NSString *)stringFromDeviceToken:(NSData *)deviceToken { NSUInteger length = deviceToken.length; if (length == 0) { return nil; } const unsigned char *buffer = deviceToken.bytes; NSMutableString *hexString = [NSMutableString stringWithCapacity:(length * 2)]; for (int i = 0; i < length; ++i) { … Read more