When is didRegisterForRemoteNotificationsWithDeviceToken called?

The application delegate will call the method upon successful registration of remote notification after you call this method in your UIApplication: (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types According to: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html When you send this message, the device initiates the registration process with Apple Push Service. If it succeeds, the application delegate receives a device token in the application:didRegisterForRemoteNotificationsWithDeviceToken: method; if … Read more

How to send APNs push messages using APNs Auth Key and standard CLI tools?

If you have curl with HTTP/2 support and openssl with ECDSA support installed on your machine, you can use the following script to test push notifications using an APNs Auth Key: #!/bin/bash deviceToken=b27371497b85611baf9052b4ccfb9641ab7fea1d01c91732149c99cc3ed9342f authKey=”./APNSAuthKey_ABC1234DEF.p8″ authKeyId=ABC1234DEF teamId=TEAM123456 bundleId=com.example.myapp endpoint=https://api.development.push.apple.com read -r -d ” payload <<-‘EOF’ { “aps”: { “badge”: 2, “category”: “mycategory”, “alert”: { “title”: “my … Read more

How to clear push notification badge count in iOS?

You should set this: [UIApplication sharedApplication].applicationIconBadgeNumber = 0; in either of these AppDelegate methods if the application is launched and sent to background then you launch the application didFinishLaunchingWithOptions method will not be called so use either of these methods: – (void)applicationWillEnterForeground:(UIApplication *)application – (void)applicationDidBecomeActive:(UIApplication *)application For Swift 3+ – func applicationWillEnterForeground(_ application: UIApplication) – … Read more

Handling Push Notifications when App is NOT running

When your app is not running or killed and you tap on push notification this function will trigger; – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions so you should handle it like this, UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (localNotif) { NSString *json = [localNotif valueForKey:@”data”]; // Parse your string to dictionary }