I am new to iOS development. I want to show an alertview on receiving a push notification while app is inactive.
Apple says that push notification can be presented in form of alert message or they can badge the application icon.
I am using PushSharp to send push notifications. But notifications are seen in notification center only. What should I do to show it on alertview?
I know we can write a code to show alertview like
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"test title" message:@"test message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alert show];
}
But this code is executed after I tap notification and app launches. I want to show alertview
as soon as device receives a push notification.
One more question, does Apple support any way to execute a code on receiving push notification though app is not launched?
Any ideas?