приложение делегат Swizzling отключено удаленные уведомления - PullRequest
1 голос
/ 06 апреля 2019

Я хочу сделать проверку телефона с помощью Firebase, но не могу отправить уведомление.Я делюсь AppDelegate кодом.Я не мог понять, что я должен был сделать?Я выполнил вставку сертификата.FirebaseAppDelegateProxyEnabled является значением no

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {

func applicationReceivedRemoteMessage(_ remoteMessage: MessagingRemoteMessage) {
  print(remoteMessage.appData)
}

func registerForPushNotifications() {
  UNUserNotificationCenter.current()
    .requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
      print("Permission granted: \(granted)") // 3
    }
  }

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  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)
    application.registerUserNotificationSettings(settings)
  }

  application.registerForRemoteNotifications()
  FirebaseApp.configure()      
}

Функция отправки кода

func sendCode(_ sender: Any) {
  let alert = UIAlertController(title: "Phone number", message: "Is this your phone number? \n \(emailField.text!)", preferredStyle: .alert)
  let action = UIAlertAction(title: "Yes", style: .default) { (UIAlertAction) in
    PhoneAuthProvider.provider().verifyPhoneNumber(self.emailField.text!, uiDelegate: nil) { (verificationID, error) in
      if error != nil {
        print("eror: \(String(describing: error?.localizedDescription))")
      } else {
        let defaults = UserDefaults.standard
        defaults.set(verificationID, forKey: "authVID")
      }
    }
  }

  let cancel = UIAlertAction(title: "No", style: .cancel, handler: nil)
  alert.addAction(action)
  alert.addAction(cancel)
  self.present(alert, animated: true, completion: nil)
}

1 Ответ

0 голосов
/ 05 июля 2019

Swift-5 Простое решение, чтобы исправить это

Remove FirebaseAppDelegateProxyEnabled Key from plist 
FirebaseAppDelegateProxyEnabled = YES/NO  //MARK: - Remove it
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...