Je suis confrontée à ce problème étrange dans mon application. J'essaie d'intégrer la notification push dans mon application en utilisant Firebase. J'ai inclus Firebase SDK dans le projet en utilisant le SDK téléchargé (n'utilisant pas de pod). J'ai inclus les cadres suivants du fichier zip téléchargé dans l'application:Notification push récupérée dans iOS mais pas dans Firebase
Dans AppDelegate
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
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()
}
// This is called and the access token is received.
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
var token = ""
for i in 0..<deviceToken.count {
token = token + String(format: "%02.2hhx", arguments: [deviceToken[i]])
}
print(token)
Messaging.messaging().setAPNSToken(deviceToken, type: .sandbox)
}
// This is not getting called
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
Messaging.messaging().subscribe(toTopic: "ios_topic")
}
Le jeton d'accès que je reçois dans didRegisterForRemoteNotificationsWithDeviceToken
est valide et je pousse envoyé avec succès au dispositif en utilisant ça. Mais le didRefreshRegistrationToken
de FireBase n'est pas appelé. J'ai ajouté -ObjC
dans linkerflags et FirebaseAppDelegateProxyEnabled
comme NO
dans info.plist
. J'ai ajouté le fichier GoogleService-Info.plist
dans la racine du projet et le projet est correctement configuré dans la console FireBase.
Quel est le problème ici et comment le résoudre?