When iPhone app is closed totally i.e. not even in background, then how APNS handling can be done. e.g. Store APNS Data in sqlite when app is completely closed.
Asked
Active
Viewed 97 times
0
-
http://stackoverflow.com/questions/19068762/will-ios-launch-my-app-into-the-background-if-it-was-force-quit-by-the-user Try this... – vijeesh Apr 27 '15 at 07:10
1 Answers
1
in AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (launchOptions)
{ //launchOptions is not nil
NSDictionary *userInfo = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
userInfoDic = userInfo;
if (apsInfo)
{ //apsInfo is not nil
[self performSelector:@selector(postNotificationToPresentPushMessagesVC)
withObject:nil
afterDelay:1];
}
}
return YES;
}
-(void)postNotificationToPresentPushMessagesVC
{
[[NSNotificationCenter defaultCenter]postNotificationName:@"recievePush" object:userInfoDic];
}
in all VC:
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recievePush:) name:@"recievePush" object:nil];
}
- (void) recievePush : (NSNotification *) notif
{
NSDictionary *dict = notif.object;
// do something with message data
}

OMGHaveFun
- 838
- 1
- 10
- 16