显示A股的iOS通知的旗帜,当你的应用程序是开放的,在前台? [英] Displaying a stock iOS notification banner when your app is open and in the foreground?

查看:252
本文介绍了显示A股的iOS通知的旗帜,当你的应用程序是开放的,在前台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在苹果官方的iOS消息应用程序是开放的,在前台,从其他联系人的新邮件触发A股的iOS通知警报旗帜。参见下图。

When Apple's official iOS Messages app is open and in the foreground, new messages from other contacts trigger a stock iOS notification alert banner. See image below.

这是可能在App Store上的第三方应用程序?本地和/或推送通知你的应用程序,而你的应用程序是开放的,在前台?

Is this possible in 3rd party apps on the app store? Local and/or push notifications for your app while your app is open and in the foreground?

在测试时的我的应用,通知接收但否的iOS UI警报显示

When testing my app, notifications are received but no iOS alert UI is shown.

但这种行为的出现在苹果的官方消息应用程序:

But this behavior is seen in Apple's official Messages app:

的<一个href=\"https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html\"相对=nofollow>本地和远程通知编程指南说:

在操作系统中提供了一个本地通知或远程通知,目标应用为在前台,它可以present通知到用户通过警报未运行,图标证件号码,或声音。

When the operating system delivers a local notification or remote notification and the target app is not running in the foreground, it can present the notification to the user through an alert, icon badge number, or sound.

如果应用程序在运行的前景时通报交付应用程序的委托接收本地或远程通知。

If the app is running in the foreground when the notification is delivered, the app delegate receives a local or remote notification.

所以,是的,我们可以收到通知,而在前台。但我看不出有什么办法present股票iOS的通知提醒用户界面。

So yes, we can receive the notification while in the foreground. But I see no way to present the stock iOS notification alert UI.

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{
    // I know we still receive the notification in the foreground.
    // This question is about displaying the stock iOS notification alert UI.

    // Yes, one *could* use a 3rd party toast alert framework. 
    [self use3rdPartyToastAlertFrameworkFromGithub]
}

时的消息,然后使用私有API来显示警报,同时在前台?

Is Messages then using a private API to display the alert while in the foreground?

有关这个问题的目的,请不要提出任何第三方的敬酒,弹出提示在github或等。我只关心这是否可以使用iOS的股票来完成本地或推送通知警报的当你的应用程序是开放的,在前台

For the purpose of this question, please do not suggest any 3rd party "toast" pop-up alerts on github or etc. I'm only interested if this can be done using the stock iOS local or push notification alerts while your application is open and in the foreground.

推荐答案

这似乎并不可能显示股票iOS的通知提醒,当您的应用程序是开放的,在前台。 Messages.app必须使用私有API。

It does not seem to be possible to show the stock iOS notification alert when your app is open and in the foreground. Messages.app must be using a private API.

该系统不显示任何警报,徽章应用程序的图标,或者发出任何声音时,应用程序已经最前面。 - <一个href=\"https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/\"相对=nofollow> UILocalNotification文档

The system does not display any alerts, badge the app’s icon, or play any sounds when the app is already frontmost. - UILocalNotification docs

UIApplicationDelegate 方法的还是被调用,让您的应用程序的本地或远程通知的回复:

The UIApplicationDelegate methods will still be called, allowing your app to respond to the local or remote notification:

application:didReceiveLocalNotification:
application:didReceiveRemoteNotification:

不过,该股的iOS通知的提醒,用户界面​​将不显示,因为它是在苹果的Messages.app,必须使用专用的API。

However, the stock iOS notification alert banner UI will not be shown as it is in Apple's Messages.app, which must be using a Private API.

你能做的最好的是在推出自己的提醒,或使用现有的框架:

The best you can do is is roll your own alert banner or use an existing framework:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{    
    // Use a 3rd party toast alert framework to display a banner 
    [self toastAlertFromGithub]
}

我会改变接受的答案,如果前景通知警报iOS中的未来版本中是可能的。如果你发现一个方法,这样做,请回答这个问题!

I will change the accepted answer if foreground notification alerts are possible in a future version of iOS. Please answer this question if you discover a method for doing so!

我已经在这里开了这种行为的雷达:rdar:// 22313177

I have opened a radar for this behavior here: rdar://22313177

这篇关于显示A股的iOS通知的旗帜,当你的应用程序是开放的,在前台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆