objective c - Custom UIView when receive push notifications and the app is active iOS -
i have implemented push notifications in app, , work well.
but i'm trying figure out how implement custom view when receive push , app active.
i replicate instagram do, (see attached photo)
but not understand how, because if app open , receive push, app show alert default, text of notification.
my code in didreceiveremotenotification
is:
-(void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { ... else if (application.applicationstate == uiapplicationstateactive) { nsstring *text = [[userinfo objectforkey:@"aps"] objectforkey:@"alert"]; nslog(@"text remotenot active = %@",text); nsstring *custom = [[userinfo objectforkey:@"aps"] objectforkey:@"custom"]; nslog(@"custom remotenot active = %@",custom); } }
so want know if standard behavior see alert default without writing code. , know how avoid showing alert default, , show custom one.
nope, if have done things correctly, notification active app not shown ios.
i suppose have
[application registerforremotenotificationtypes:(uiremotenotificationtypebadge | uiremotenotificationtypesound | uiremotenotificationtypealert)];
and checked that
- (void)application:(uiapplication *)app didregisterforremotenotificationswithdevicetoken:(nsdata *)devtoken
is correctly called.
note there new version of remote notification handler:
- (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo fetchcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler;
if have 1 defined, "old" 1 not called.
are sure notification sent "right" app? it's easy mix things in development...
Comments
Post a Comment