2015-09-15 114 views
0

我與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 

我怎樣才能得到關於控制器捕獲這些通知,然後做一些基於特定的通知這是拋出?

+0

閱讀NSNotificationCenter的文檔。 – rmaddy

回答

1

您將需要添加您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 
    } 

} 
+0

省長致謝! – Deekor