Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

push notification testing in device through xcode with development SSL certificate

My app is already on the app store and with push notifications active and working (using production certificate). Now I need to add badges (before their were only alerts) in the application (already implemented on the server side). So for testing I would need a development SSL certificate. So following are my queries:

  1. Do I have to install the development SSL certificate on my server so that I can test on iPhone using development cert?
  2. Will it not conflict with the already installed production SSL cert on the server.
  3. Do I have to add badges in both didReceiveRemoteNotification: and didFinishLaunchingWithOptions: delegates using below code:

code section:

NSString* alertValue = [[userInfo valueForKey:@"aps"] valueForKey:@"badge"];  
NSLog(@"my message-- %@",alertValue);  
int badgeValue= [alertValue intValue];  
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeValue];

Any suggestions?

like image 467
user2268539 Avatar asked Dec 03 '25 16:12

user2268539


2 Answers

Just to add some additional color to the Certificate/Server/SSL questions and answers that have been proposed:

Prod/Sandbox APNS Picked Based on Codesign Settings

For the sake of being thorough, lets start with a quick review of the APNS environment:

  • Applications that are Code Signed with an iOS Development certificate connect to and wait for Push Notifications to be delivered from the Sandbox APNS Environment
  • Applications that are Code Signed with an iOS Distribution certificate (AppStore or Distribution > Ad-Hoc) connect to and wait for Push Notification to be delivered from the Production APNS Environment.
  • This setting is automatically determined by Xcode during the build process and is only configurable by selecting the type of certificate used in the CodeSign step.

Question 1: Do I have to install the Development SSL Certificate on my Server to Test Development Certificate Signed Apps Push Notifications?

Yes, once and app is Code Signed, its APNS setting is sealed into the binary using the rules in the previous section. It is then up to the Developer's server code to know that the APNS token that device will generate goes with the Sandbox APNS environment and that the server should route that request for a push notification to gateway.sandbox.push.apple.com instead.

Some developers choose to setup a single server that is capable of making these distinctions while others choose to setup side-by-side instances of their servers one set to send to Production and another set to send to the Sandbox.

Either way, the decision resides with the individual developer and what their server-side code is capable of doing and the relative complexity of setting up a second server. Either way, users might get upset if you accidentally disabled Production push notifications while testing out upcoming features then forgot to reenable them later, so definitely be careful when poking around production code!

Question #2: Will the Development and Production SSL Certificate Conflict?

From the raw SSL standpoint no they won't conflict -- you should be able to download and open/examine both of those certificates on a machine other than the server and see that the contents of the certificates are in fact different. Importing them into the same server environment (again from an SSL perspective) is perfectly allowable. To ensure they are different, when requesting the certificates make absolutely sure you create two different certificateSigningRequests and you'll inherently wind up with different data.

From the Developer's Server-side Push Code standpoint -- It depends. See the conversation in Question 1 regarding server-side code capabilities. If the server-code was designed with this in mind then in theory the answer is also 'No they will not conflict', but that is a determination the individual developer needs to make about their own server-side code capabilities.

like image 108
Bryan Musial Avatar answered Dec 06 '25 06:12

Bryan Musial


  1. Yes, you should install the development SSL certificate on server. You also have to use sandbox push-notification service (gateway.sandbox.push.apple.com) with this certificate.

  2. I guess they won't conflict. You should just use production SSL for AppStore app, and development SSL for test app.

  3. It's better not to increment or decrement or set badge value in code. Your server should return badge value in notifications body. For example, You can't handle push when your app is not running, thus you cant change badge value in code. But if your push contains badge value, it will be set and displayed correctly any way.

Here is the notification body example. Pass badge value for key "badge": {"aps":{"alert":"This is message.","badge":7}}

By the way, didReceiveRemoteNotification: method always called when you app receives push. Even if the app is down, it will be called when you launch the app from push.

like image 25
Rafael Kayumov Avatar answered Dec 06 '25 05:12

Rafael Kayumov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!