简体   繁体   English

当应用运行时,iOS推送通知显示为UIAlert

[英]iOS Push Notification Shows up as UIAlert when App is Running

I have push notifications successfully set up on my app. 我已经在我的应用程序上成功设置了推送通知。 When I send a push to a user when they are not running the app they receive it banner-style as they should. 当我在用户未运行应用程序时向其发送推送时,他们会按应有的方式收到横幅广告。

However, when a user has the app open, instead of displaying the push notification as a banner it shows up as a UIAlert. 但是,当用户打开该应用程序时,它不会将推送通知显示为横幅,而是显示为UIAlert。 Receiving pushes only behaves this way when the app is open. 接收推送仅在打开应用程序时才如此。

I have the "Alert Style When Unlocked" set up as "Banner" (on both phones), and this behavior persists. 我将“解锁时的警报样式”设置为“横幅”(在两部手机上),并且此行为仍然存在。

When Applicationn is running you will get call in didReceiveRemoteNotification method on AppDelegate Class , so now you can handle notification here : 当Applicationn运行时,您将在AppDelegate类的didReceiveRemoteNotification方法中得到调用,因此现在您可以在此处处理通知:

Now You can create a custom view and add it to your application main window as a banner. 现在,您可以创建一个自定义视图,并将其作为横幅添加到您的应用程序主窗口中。

The settings is for App in background, show as Banner or Alert. 设置适用于后台应用程序,显示为横幅或警报。 When App is opened it calls didReceiveRemoteNotification directly, and no Banner or Alert show up. 打开应用程序后,它将直接调用didReceiveRemoteNotification ,并且不会显示横幅或警报。

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

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