When my app is opened and it receives push notification alert is shown.
当我的应用程序打开并收到推送通知时,会显示警报。
I want to remove it. I tried to remove key alert
in payload, but then all notifications including one when the app is closed are gone.
我想删除它。我试图删除有效负载中的关键警报,但是当应用程序关闭时所有通知(包括一个通知)都消失了。
How can I disable alert only and prevent it from appearing ?
如何仅禁用警报并防止其出现?
2 个解决方案
#1
1
Comment out the line
注释掉这条线
PFPush.handlePush(userInfo)
in your didReceiveRemoteNotification
method. Parse api is showing that alert.
在您的didReceiveRemoteNotification方法中。 Parse api正在显示警报。
查看此链接了解详细信息
#2
-1
You can do it in your AppDelegate.m
where you have configured the delegate of receiving push notification like below
您可以在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];
}
Or UIAlertController
if you are using iOS 8.0 or Later
如果您使用的是iOS 8.0或更高版本,请使用UIAlertController
#1
1
Comment out the line
注释掉这条线
PFPush.handlePush(userInfo)
in your didReceiveRemoteNotification
method. Parse api is showing that alert.
在您的didReceiveRemoteNotification方法中。 Parse api正在显示警报。
查看此链接了解详细信息
#2
-1
You can do it in your AppDelegate.m
where you have configured the delegate of receiving push notification like below
您可以在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];
}
Or UIAlertController
if you are using iOS 8.0 or Later
如果您使用的是iOS 8.0或更高版本,请使用UIAlertController