Thursday, 15 August 2013

Parse - How to stop modal alert while app opening(foreground), when received remote notification IOS? -



Parse - How to stop modal alert while app opening(foreground), when received remote notification IOS? -

i have problem during developing application ios , used parse force notification framework force remote notification. problem when application running , same time notification has been sent, application display modal alert box automatically. so, don't want modal alert display. spent much times on it, , research on internet, read documents no result found, sense nobody knew this. please help me!

appdelegate.m

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch. uiimage *navbackgroundimage = [uiimage imagenamed:@"nav_bg_new"]; [[uinavigationbar appearance] setbackgroundimage:navbackgroundimage forbarmetrics:uibarmetricsdefault]; [[uinavigationbar appearance] settitletextattributes:@{nsforegroundcolorattributename : [uicolor whitecolor]}]; // **************************************************************************** // uncomment , fill in parse credentials: // [parse setapplicationid:@"your_application_id" clientkey:@"your_client_key"]; // **************************************************************************** [parse setapplicationid:@"my_app_id" clientkey:@"my_client_key"]; // override point customization after application launch. [application registerforremotenotificationtypes:uiremotenotificationtypebadge|uiremotenotificationtypesound]; homecoming yes; } - (void)applicationwillresignactive:(uiapplication *)application { // sent when application move active inactive state. can occur types of temporary interruptions (such incoming phone phone call or sms message) or when user quits application , begins transition background state. // utilize method pause ongoing tasks, disable timers, , throttle downwards opengl es frame rates. games should utilize method pause game. } - (void)applicationdidenterbackground:(uiapplication *)application { // utilize method release shared resources, save user data, invalidate timers, , store plenty application state info restore application current state in case terminated later. // if application supports background execution, method called instead of applicationwillterminate: when user quits. } - (void)applicationwillenterforeground:(uiapplication *)application { // called part of transition background inactive state; here can undo many of changes made on entering background. } - (void)applicationdidbecomeactive:(uiapplication *)application { // restart tasks paused (or not yet started) while application inactive. if application in background, optionally refresh user interface. } - (void)applicationwillterminate:(uiapplication *)application { // called when application terminate. save info if appropriate. see applicationdidenterbackground:. } - (void)application:(uiapplication *)application didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken { pfinstallation *currentinstallation = [pfinstallation currentinstallation]; [currentinstallation setdevicetokenfromdata:devicetoken]; currentinstallation.channels = @[@"global"]; [currentinstallation saveinbackground]; } - (void)application:(uiapplication *)application didfailtoregisterforremotenotificationswitherror:(nserror *)error { if (error.code == 3010) { nslog(@"push notifications not supported in ios simulator."); } else { // show alert or otherwise handle failure register. nslog(@"application:didfailtoregisterforremotenotificationswitherror: %@", error); } } - (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { [pfpush handlepush:userinfo]; }

thanks much in advance.

if want create sure not see notifications when app opening, set bool isopening true in application:willfinishlaunchingwithoptions: , set false during application:didfinishinglaunchingwithoptions:, alter behavior of didreceiveremotenotification: , phone call pfpush handlepush: accordingly.

you can seek instead:

@property (nonatomic, assign) bool islaunching; - (void)applicationwillenterforeground:(uiapplication *)application { islaunching = true; } - (void)applicationdidenterforeground:(uiapplication *)application { islaunching = false; } - (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { if (!islaunching) { //only fire force handler if application isn't active [pfpush handlepush:userinfo]; } }

ios notifications parse.com push

No comments:

Post a Comment