1

Here is an issue that is giving me a real headache. We are developing a cross platform application where we need Push Notifications. We have a server syncing every app, and in case the app is not running on one device, we notify the latter if we need to. Push is working fine on the other platform.

The weird thing is that: notifications works well if the app has been opened recently. But after a few hours, the server needs to send at least two notifications (if it's not more) before I can receive one on the device. If the app HAS been opened recently, everything words fine.

The problem can come from:
- The server side. our server API is in C# and we use "APNS Sharp" to send notification to Apple's servers.
- Apple's side (not likely i Guess)
- The iphone app. But then, why would I receive one from time to time ? I also noticed that sometime, I receive the notification, but then the blue bubble that pops on the screen disappear after a few seconds and even immediately sometimes. Here is a snippet of my code in my App Delegate :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    NSLog(@"Registering for remote notifications"); 
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
return YES;
}

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {

    NSString * tokenAsString = [[[[devToken description] 
                             stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]] 
                            stringByReplacingOccurrencesOfString:@" " withString:@""] retain];
    [self sendToken:tokenAsString];
NSLog(@"enregistré");
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
    NSLog(@"Error in registration. Error: %@", err);
}

The following function is a function of my own to send the device token to our server. No need to display this.
[self sendToken:tokenAsString];

Does anyone have ever heard of such an issue ? Do you think, based on the code snippet that it could come from the app or Apple's servers ? Should we orientate our search more on the server side ?

Thanks a lot.

Pierre

EDIT

Turned out to be a server issue. Apple recommends to keep an open connection to their server to limit the amount of connect/disconnect request. We tried to open one at each time and now it is working properly.

Pierre
  • 1,053
  • 7
  • 17

1 Answers1

0

For those who might be interested, this was a server issue. Apple recommends that we keep the connection open to avoid too many connections request.

I'm not really sure how this API works, but we tried to open it once in a while instead (if not for every message) and it works like a charm now. Nothing was wrong in the config on the app above.

Cheers

Pierre
  • 1,053
  • 7
  • 17
  • may i know which certificate are you used in the server? aps_development or aps_production – Bharathi D Aug 04 '12 at 10:44
  • we actually have both.. for our tests/qa versions and prod versions. – Pierre Aug 06 '12 at 17:24
  • for app store submission what certificate we want to use? – Bharathi D Aug 07 '12 at 12:48
  • 1
    The prod one ! If you actually want to use more than one certificate, you may need to do something in your app to specify which version of the client you're using (i.e. is it a prod or test client), let the server know so that it can use the proper certificate. I don't think Apple is checking which certificate you're using, because they can't really know if you're sending the notification to a test or prod client.. – Pierre Aug 09 '12 at 08:19