gpt4 book ai didi

ios - 捕捉通知并做某事

转载 作者:行者123 更新时间:2023-11-29 01:39:20 26 4
gpt4 key购买 nike

我正在与 Intercom's iOS SDK 合作并阅读可用的标题,我发现:

//=========================================================================================================
/*! @name Intercom Notifications */
//=========================================================================================================

/*!
These are notifications thrown by Intercom for iOS when the Intercom window is displayed and hidden or when
a new conversation has been started. These notifications are fired only when there is a change in the state
of Intercom's UI: when a user receives a message for instance, willShow and didShow notifications will be
fired accordingly when the Intercom Notification (chat head) is presented.

Once the user taps on the chat head, the message is presented in your app. It will be presented covering
the entire screen, but no notifications will be thrown here as Intercom has already been visible.

In the case of a new conversation this notification may be used to prompt users to enable push notifications.
*/

let IntercomWindowWillShowNotification: String
let IntercomWindowDidShowNotification: String
let IntercomWindowWillHideNotification: String
let IntercomWindowDidHideNotification: String
let IntercomDidStartNewConversationNotification: String

如何在 Controller 中捕获这些通知,然后根据抛出的特定通知执行某些操作?

最佳答案

您需要将 ViewControllerClass 作为观察者添加到它应在 viewDidLoad 中观察到的每个通知...

class ITC: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("icWindowWillShowNotification:"), name: IntercomWindowWillShowNotification, object: nil)
}

deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}

func icWindowWillShowNotification (notification: NSNotification) {
//Do something
}

}

关于ios - 捕捉通知并做某事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32594890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com