Ios 应用程序代理swizzling已禁用远程通知
我想与Firebase进行电话验证,但我无法发送通知。我正在共享Ios 应用程序代理swizzling已禁用远程通知,ios,swift,firebase,Ios,Swift,Firebase,我想与Firebase进行电话验证,但我无法发送通知。我正在共享AppDelegatecode。我不知道我该怎么做?我执行了证书插入FirebaseAppDelegateProxyEnabled是值no class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate { func applicationReceivedRemoteMessage(
AppDelegate
code。我不知道我该怎么做?我执行了证书插入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)
}
您对推送通知证书做了什么?是的,我无缝地添加了它。当我使用Firebase发送通知时,它会起作用。好的,您发送的负载是什么?我将其添加到主题中。您是否使用云功能发送通知?您对推送通知证书做了什么?是的,我无缝添加了它。当我使用Firebase发送通知时,它会起作用。好的,您发送的负载是什么?我已将其添加到主题中。您是否使用云功能发送通知?