title: Swift 5 - Not able to receive Push Notification through FCM
body: <p>I am having trouble with getting push notification, here's my payload</p>
  <pre><code>{
    &quot;to&quot;: &quot;erOZW7CN....(fcm token)&quot;,
    &quot;data&quot;: {
      &quot;body&quot;: &quot;Incoming-Call&quot;,
      &quot;title&quot;: &quot;AppName&quot;,
      &quot;type&quot;: &quot;incoming-call&quot;,
      &quot;number&quot;: &quot;0212222222&quot;
    },
    &quot;aps&quot;: {
      &quot;alert&quot;: {
        &quot;title&quot;: &quot;AppName&quot;,
        &quot;body&quot;: &quot;Incoming-Call&quot;
      }
    }
  }
  </code></pre>
  <p>The <code>data</code> part is for Android. When I use <code>notification</code> instead of <code>aps</code> it works but the Android side gets buggy. So I need to use <code>aps</code> to detect request. I've done lots of research but couldn't find any solution.</p>
  <p><strong>Here's my AppDelegate</strong></p>
  <pre><code>import UIKit
  import CoreData
  import Firebase
  import Network
  
  
  @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
  
  
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {
          // Override point for customization after application launch.
          
          FirebaseApp.configure()
          
          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 })
          } else {
            let settings: UIUserNotificationSettings =
            UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings)
          }
  
          application.registerForRemoteNotifications()
          Messaging.messaging().delegate = self
          
          return true
      }
      
  
      
      // MARK: UISceneSession Lifecycle
  
      func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -&gt; UISceneConfiguration {
          return UISceneConfiguration(name: &quot;Default Configuration&quot;, sessionRole: connectingSceneSession.role)
      }
  
      @available(iOS 13.0, *)
      func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set&lt;UISceneSession&gt;) {
  
      }
      
      lazy var persistentContainer: NSPersistentContainer = {
          let container = NSPersistentContainer(name: &quot;Database&quot;)
          container.loadPersistentStores(completionHandler: { (storeDescription, error) in
              if let error = error as NSError? {
                  fatalError(&quot;Unresolved error \(error), \(error.userInfo)&quot;)
              }
          })
          return container
      }()
      
      func saveContext () {
          let context = persistentContainer.viewContext
          if context.hasChanges {
              do {
                  try context.save()
              } catch {
                  let nserror = error as NSError
                  fatalError(&quot;Unresolved error \(nserror), \(nserror.userInfo)&quot;)
              }
          }
      }
  
      func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
          Messaging.messaging().apnsToken = deviceToken
      }
      
  
      func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
          print(&quot;Firebase registration token: \(fcmToken)&quot;)
  
          let dataDict:[String: String] = [&quot;token&quot;: fcmToken]
          NotificationCenter.default.post(name: Notification.Name(&quot;FCMToken&quot;), object: nil, userInfo: dataDict)
          UserDefaults.standard.set(fcmToken, forKey: &quot;fcmToken&quot;)
      }
      
      func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -&gt; Void) {
          print(&quot;Push Received: \(userInfo)&quot;)
          //TODO: CALLKIT DETECT
      }
  }
  </code></pre>
  <p>Note: I am sending request from Postman</p>
  <p>Would be great to find a solution here. Thanks.</p>