简体   繁体   English

将iOS推送通知显示为警报弹出窗口而不是横幅样式

[英]Show iOS push notifications as alert popup instead of banner style

I'm registering my app for receiving push notifications from APNS in application:didFinishLaunchingWithOptions: method this way: 我正在注册我的应用程序,以便在application:didFinishLaunchingWithOptions:程序中接收来自APNS推送通知application:didFinishLaunchingWithOptions:方法:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

The registration is ok and my provider succesfully gets my token, in fact I do receive push notifications, but when my app is not in foreground a banner is displayed. 注册正常,我的提供商成功获取我的令牌,事实上我确实收到推送通知,但当我的应用程序不在前台时,会显示横幅。 I expected an alert to be shown, with 'Close' and 'View' buttons, and I receive the "alert" string in the payload dictionary... what could be happening? 我期望通过“关闭”和“查看”按钮显示警报,并且我在有效负载字典中收到“警报”字符串......可能会发生什么?

Check the phone settings, users can customize how they want Push Notifications to appear on their devices. 检查手机设置,用户可以自定义推送通知在其设备上的显示方式。

  1. Go to 'Settings' app on your iOS device. 转到iOS设备上的“设置”应用。
  2. Then choose 'Notifications' 然后选择“通知”
  3. Tap on your app's name which is displayed in the list 点击列表中显示的应用程序名称
  4. Change display settings for push notifications (screen shot below) 更改推送通知的显示设置(下面的屏幕截图)

iPhone推送设置

You can not change this setting using code (Reference: https://stackoverflow.com/a/9137501/ ) 无法使用代码更改此设置(参考: https//stackoverflow.com/a/9137501/

However, you may check the current setting and then request the user to change it. 但是,您可以检查当前设置 ,然后请求用户进行更改。

转到Settings->Notifications->select Your App->Alert style(None,Banners,Alert) select Alerts.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM