We want to create a ios application, whose working is mainly depends on Apple push notification. We have created server for this and server sends message successfully. But the problem is that application won't receiving messages when it goes background and not connected xcode for silent push messages. At the same time it works properly when it connected to xcode through usb.
The Json payload I had send from server as follows
{"aps":{"content-available":1},"data":"hai"}
Code written "didReceiveRemoteNotification" is
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
DEBUG_LOG(@"Remote notification received from server, silent mode");
if(application.applicationState == UIApplicationStateInactive) {
DEBUG_LOG(@"Application is not active now, suspended state");
[self callNotificationMethod:@"Inactive"];
} else if (application.applicationState == UIApplicationStateBackground) {
DEBUG_LOG(@"Application is not active now, background state");
[self callNotificationMethod:@"Background"];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"CallOriginatedEvent"
message:@""
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"showTitle", nil];
[alert show];
}
completionHandler(UIBackgroundFetchResultNewData);
}
Testing platform OS version : IOS 8.1 and above Devices:iPhone 5C,iPhone 5S,iPhone 6, iPhone 6+
Please advise.. Thanks in advance