收到推送通知并打开应用程序时如何禁用警报?
How to disable alert when push notification is received and app is opened?
当我的应用程序打开并收到推送通知时显示警报。
我想删除它。我试图删除有效负载中的密钥 alert
,但随后所有通知(包括应用关闭时的通知)都消失了。
如何仅禁用警报并防止它出现?
您可以在您的 AppDelegate.m
中执行此操作,您已经配置了接收推送通知的委托,如下所示
-(void)onReceivePushNotification:(NSDictionary *) pushDict andPayload:(NSDictionary *)payload {
[payload valueForKey:@"title"];
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Alert !" message:[pushDict valueForKey:@"alert"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil ,nil];
[message setTag:kAlertViewPushNotification];
if([UIApplication sharedApplication].applicationState == UIApplicationStateInActive)
[message show];
}
或 UIAlertController
如果您使用 iOS 8.0 or Later
注释掉行
PFPush.handlePush(userInfo)
在您的 didReceiveRemoteNotification
方法中。 Parse api 正在显示该警报。
当我的应用程序打开并收到推送通知时显示警报。
我想删除它。我试图删除有效负载中的密钥 alert
,但随后所有通知(包括应用关闭时的通知)都消失了。
如何仅禁用警报并防止它出现?
您可以在您的 AppDelegate.m
中执行此操作,您已经配置了接收推送通知的委托,如下所示
-(void)onReceivePushNotification:(NSDictionary *) pushDict andPayload:(NSDictionary *)payload {
[payload valueForKey:@"title"];
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Alert !" message:[pushDict valueForKey:@"alert"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil ,nil];
[message setTag:kAlertViewPushNotification];
if([UIApplication sharedApplication].applicationState == UIApplicationStateInActive)
[message show];
}
或 UIAlertController
如果您使用 iOS 8.0 or Later
注释掉行
PFPush.handlePush(userInfo)
在您的 didReceiveRemoteNotification
方法中。 Parse api 正在显示该警报。