Push Notification - GluedIn
Push Notification Integration document
IOS Step to Integrate push notification in the parent app
  • Firebase integration document:
    Below are the step-wise integration detail:
    • Create a firebase project on : https://console.firebase.google.com/
    • Register your app with firebase:
      • implementation 'com.gluedin.lowcode.creator:creator:2.0.0'
      • Add Bundle id, app name, App store id and other important information
      • Click on register button
    • Add Firebase configuration file into your application
      • download googleservice-info.plist file and drag-drop into your application
      • Add the required firebase dependency
    • Enable Push Notification in Firebase Cloud Messaging Console
      • Go to project setting → Cloud messaging tab
      • Add APNs auth key or APNs .p12 certificate into firebase console
      • Add the Firebase cloud messaging required dependance into your pod file and run 'pod install' command.
    • Configuration setting into application
      • Enable “Push Notifications” capabilities in Xcode, by selecting the build target and then Capabilities tab
      • Write a code to generate push notification token and method to handle notification:
          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()
        }
        
          
          
      • Get FCM token for internal server
      • func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
          updateFirestorePushTokenIfNeeded()
        }
          
          
    • Receive Notification:
      
      func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
            print(response)
       }
        
        
  • Gluedin method which need to call from notification receive protocol method:
    Below are the defined cases for push notification where we need to open the feed controller with single video:
    • Case: Like
    • Case: Comment
    • Case: Tagging
    • Case: Inactive
      // 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
     }
      
      
    Below are the defined cases for push notification where we need to open the user profile controller with single video:
  • Case: Follow the user
      guard let userId = feed?.userId ?? feed?.user?.userId else { return }
    feedDelegate?.didSelectProfile(
        feedModel: feed, 
        profileId: userId, 
        navigationController: navigationController ?? UINavigationController()
     )
      
      
  • Case: User Inactive
      Auth?.logout()
    // Navigate back to login screen or any other authentication flow which you are follwoing