We got plenty of applications powered by Apple Push notification feature and even we know how it's implemented.
At the end when it comes for testing, simulator won’t help you out. We need actual hardware device. Since Xcode 7, you can now test apps on your device without a program membership. However, to configure push notifications you need a push notification certificate for your App ID, which requires the program membership.
Now assume that your server is not ready to trigger notifications. Well, it doesn't stop you testing and see the magic working ! Listed below best options for the same.
From online portals :
From Mac app :
I have used NWPusher and I will recommend the same. ;-)
So, here its recipe
Key items
[1] PEM file
[2] Device token (64bit hex number)
[3] Payload string
Preparation
In member center ,
[1] Your testing device added into device list.
[2] Generated Provisional profile with the device
[3] Generated signing certificate for development - Apple Push Notification service SSL (Sandbox)
In you Mac,
Create
Apple Push Notification service SSL (Sandbox) and add into keychain store. Later export these 2 items into .p12
Run the command in terminal will export into .pem
$openssl pkcs12 -in your_certificate_name.p12 -out your_certificate_name.pem -nodes –clcerts
Now, download and install “Pusher” from git if you are not done
-OR-
Install it from HomeBrew :
$ brew cask install pusher
In Xcode ,
* Make sure that YourProject -> Target -> Capabilities must enable Push notification.
* You can collect generated device token from the Delegate `didRegisterForRemoteNotificationsWithDeviceToken ` :
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSString *token = [deviceToken.description stringByReplacingOccurrencesOfString:@" " withString:@""]; token = [token stringByReplacingOccurrencesOfString:@"<" withString:@""]; token = [token stringByReplacingOccurrencesOfString:@">" withString:@""]; NSLog(@"%@", token); }
Note down the device token and below sample string as payload.
"{"aps":{"alert":"Testing..","badge":1,"sound":"default”}}”
Now open NWPusher app and select Push Certificate. Sandbox certificate selected in my example.
Then enter device token. Customise pay load and past it in last box. The hit push button. Next moment you will be notified to relax ;-)