func registerForPushNotifications() {
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
// For iOS 10 data message (sent via FCM)
Messaging.messaging().delegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
UIApplication.shared.registerUserNotificationSettings(settings)
}
UIApplication.shared.registerForRemoteNotifications()
}
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
updateFirestorePushTokenIfNeeded()
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
print(response)
}
// For Card based Feed:
// getVideoFeedType = .card
// Set isVerticalFeed = 0 in info plist file
public func getFeedViewControllerWithUrlAndVideos(context: PlayerContext?,
url: String?,
searchText: String?,
sourcePageName: String?,
currentPage: Int?,
videos: [FeedModel]?,
index: Int?,
delegate: FeedDelegate?,
isBackEnable: Bool?) -> UIViewController? {
// Return could be Vertical and card based on info.plist file setting
// Vertical player
let viewController = routerViewController(viewController: ViewControllers.PlusSAW.verticalFeed, parameters: parameters)
return viewController
// For card player
let viewController = routerViewController(viewController: ViewControllers.PlusSAW.listingFeed,parameters: parameters)
return viewController
}
// Vertical Feed:
public func getVerticalFeedViewControllerWithUrlAndVideos(context: PlayerContext?,
url: String?,
searchText: String?,
sourcePageName: String?,
currentPage: Int?,
videos: [FeedModel]?,
index: Int?,
delegate: FeedDelegate?,
isBackEnable: Bool?,
isMenuEnable: Bool? = true) -> UIViewController? {
return vertical player controller
}
guard let userId = feed?.userId ?? feed?.user?.userId else { return }
feedDelegate?.didSelectProfile(
feedModel: feed,
profileId: userId,
navigationController: navigationController ?? UINavigationController()
)
Auth?.logout()
// Navigate back to login screen or any other authentication flow which you are follwoing