title: Push Notifications don't appear on devices
body: <p>I have already written a lot of code in which I set notifications and try to send a notification from a user to another but now here is my problem, there isn't any notification that appears on the other user's device. The app doesn't crash and I have don't have build failed so I really don't know where I am wrong. Thanks in advance for your answers, here's my code...</p>
  
  <p>// Parts about push notifications in AppDelegate.swift</p>
  
  <pre><code>static let NOTIFICATION_URL = "https://gcm-http.googleapis.com/gcm/send"
  static var DEVICEID = String()
  static let SERVERKEY = "AAAAuIcRiYI:APA91bHA8Q4IJBG9dG4RY9YOZ3v4MlcVZjmYs3XhiMY3xpQm3bTSjrINUiImaE0t17Y6mghR2vN1ezJTMSVFmHlgOUBX8KQZEckgwCkc1tlMdpm_UjxobmrHf3GbvwrKtHVZsJR-v1GG"
  
  #available(iOS 10.0, *){
          UNUserNotificationCenter.current().delegate = self
          // Request Autorization.
          let option : UNAuthorizationOptions = [.alert,.badge,.sound]
          UNUserNotificationCenter.current().requestAuthorization(options: option) { (bool, err) in
          }
      }
      else{
          let settings : UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert,.badge,.sound], categories: nil)
          application.registerUserNotificationSettings(settings)
      }
      application.registerForRemoteNotifications()
      UIApplication.shared.applicationIconBadgeNumber = 0
  
  func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
      guard  let newToken = InstanceID.instanceID().token() else {return}
      AppDelegate.DEVICEID = newToken
      connectToFCM()
  }
  
  func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -&gt; Void) {
  
      let notification =  response.notification.request.content.body
      print(notification)
      completionHandler()
  }
  
  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
      guard let token = InstanceID.instanceID().token() else {return}
  
      AppDelegate.DEVICEID = token
      print(token)
      connectToFCM()
  }
  
  func connectToFCM()
  {
      Messaging.messaging().shouldEstablishDirectChannel = true
  }
  </code></pre>
  
  <p>// Parts about notifications in messages.swift, I call this function after the user sends a message in way that the person who receives the message receives at the same time a notification.</p>
  
  <pre><code>fileprivate func setupPushNotification(fromDevice:String)
  {
  
      Database.database().reference().child("users").child(userID).observeSingleEvent(of: .value, with: { (snapshot) in
  
          let value = snapshot.value as? NSDictionary
          let device = value?["device"] as? String ?? ""
  
      guard let message = self.authorText else {return}
      let title = "You received a new message !"
      let body = "from \(message)"
      let toDeviceID = device
      var headers:HTTPHeaders = HTTPHeaders()
  
      headers = ["Content-Type":"application/json","Authorization":"key=\(AppDelegate.SERVERKEY)"
  
      ]
      let notification = ["to":"\(toDeviceID)","notification":["body":body,"title":title,"badge":1,"sound":"default"]] as [String:Any]
  
      Alamofire.request(AppDelegate.NOTIFICATION_URL as URLConvertible, method: .post as HTTPMethod, parameters: notification, encoding: JSONEncoding.default, headers: headers).responseJSON { (response) in
          print(response)
      }
      })
  
  }
  </code></pre>