Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

Notifications

Rajul Arora edited this page Nov 14, 2017 · 1 revision

Twitter Kit provides several types of notifications when users perform certain actions. All of these notifications may be found inside the TWTRNotificationConstants.h file.

Tweet View Actions

There are several notifications that are posted when the user performs certain actions on the Tweet view. On each of these notifications, the userInfo property of the NSNotification contains a TWTRNotificationInfoTweet key with the associated Tweet module object as the value.

The TWTRDidSelectTweetNotification is posted when a user taps on a Tweet.

The TWTRDidShowTweetDetailNotification is posted when a user taps on a Tweet, and the developer allows the Tweet Detail view controller to be shown full-screen. This will not be posted if the developer has implemented the tweetView:shouldDisplayDetailViewController: and returned NO.

The TWTRWillShareTweetNotification is posted when a user taps the Share button on a Tweet view. This will always be followed by one of the following notifications: TWTRDidShareTweetNotification, or TWTRCancelledShareTweetNotification.

When a user taps the Like button on a Tweet, Twitter Kit will post either TWTRDidLikeTweetNotification if the Tweet was previously unliked, or TWTRDidUnlikeTweetNotification if the Tweet was previously liked.

Media State Changes

When the a video begins playing, a TWTRVideoPlaybackStateChangedNotification is posted with userInfo of {TWTRVideoPlaybackStateKey: TWTRVideoStateValuePlaying}.

When the a video is paused, a TWTRVideoPlaybackStateChangedNotification is posted with userInfo of {TWTRVideoPlaybackStateKey: TWTRVideoStateValuePaused}.

When the a video finished playing, a TWTRVideoPlaybackStateChangedNotification is posted with userInfo of {TWTRVideoPlaybackStateKey: TWTRVideoStateValueCompleted}.

Video Presentation/Dismissal

When a user taps on a video and a full-screen player is presented Twitter Kit posts a TWTRWillPresentVideoNotification notification. You can observe this notification and inspect the object property of the NSNotification to view the UIViewController displaying the video. You may also inspect the userInfo property of the notification to view what type of video is being displayed. The TWTRVideoTypeKey will have as a value either TWTRVideoTypeStandard, TWTRVideoTypeGIF, or TWTRVideoTypeVine.

When the video view controller is dismissed by the user Twitter Kit posts the TWTRDidDismissVideoNotification.

Authentication Events

When a user authenticates with Twitter Kit, a TWTRUserDidLogInNotification is posted. The user ID of the logged-in user may be accessed from the userInfo dictionary property of the notification using the TWTRLoggedInUserIDKey. Note: this notification may be posted as a result of starting the Twitter object.

When a user logs out using Twitter Kit, a TWTRUserDidLogOutNotification is posted. It also contains the user ID of the logged-out user in the userInfo dictionary with the TWTRLoggedOutUserIDKey.