Я использую Swift4:
Я хочу создать push-уведомление firebase, я бы следовал инструкциям, приведенным в этом видео push-уведомление firebase
и это код делегата приложения:
import UIKit
import IQKeyboardManagerSwift
import FBSDKLoginKit
import TwitterKit
import Firebase
import FirebaseMessaging
import FirebaseInstanceID
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
print("user tooooken: ", Common.getUserToken())
FirebaseApp.configure()
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (success, error) in
if(error == nil) {
print("successful authentication")
}
}
application.registerForRemoteNotifications()
NotificationCenter.default.addObserver(self, selector: #selector(self.refreshToken(notification:)), name: NSNotification.Name.InstanceIDTokenRefresh, object: nil)
UIApplication.shared.statusBarView?.backgroundColor = UIColor(red:255/255.0, green:51/255.0, blue:255/255.0, alpha: 1.0);
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
TWTRTwitter.sharedInstance().start(withConsumerKey:"xxxxxxxxxxx", consumerSecret:"xxxxxxxxxxxxxxxxxx")
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func applicationWillResignActive(_ application: UIApplication) {
FBSDKAppEvents.activateApp()
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
func applicationDidEnterBackground(_ application: UIApplication) {
Messaging.messaging().shouldEstablishDirectChannel = false
}
func applicationDidBecomeActive(_ application: UIApplication) {
FBHandler()
}
///// Twitter authentication //////
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if TWTRTwitter.sharedInstance().application(app, open: url, options: options) {
return true
}
return true
}
@objc func refreshToken(notification: NSNotification) {
let refreshToken = InstanceID.instanceID().token()!
print(refreshToken)
FBHandler()
}
func FBHandler() {
Messaging.messaging().shouldEstablishDirectChannel = true
}
}
когда я отправляю уведомление с firebase-сервера, оно успешно доставлено на устройство, но когда php-сервер отправляет push-уведомление, оно не работает, я забываю какой-нибудь шаг?