Mehemmed Rustemzade Mehemmed Rustemzade - 1 year ago 284
Swift Question

Firebase Notification not working on Testflight

I have created app with notification. When i send notification on developer mode then i get notifications. but when i send on release mod i don't get anything. I read that i should change certificate to product certificat. But it doesn't helped. here is my appdelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.


let notificationTypes : UIUserNotificationType = [.alert, .badge, .sound]
let notificationSettings : UIUserNotificationSettings = UIUserNotificationSettings(types: notificationTypes, categories: nil)

return true

private func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
FIRMessaging.messaging().subscribe(toTopic: "/topics/main")

private func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)
FIRInstanceID.instanceID().setAPNSToken(deviceToken as Data, type:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

func application(_ application: UIApplication, dirtings: UIUserNotificationSettings)

func tokenRefreshNotification(notification: NSNotification) {
if let refreshedToken = FIRInstanceID.instanceID().token() {
print("InstanceID token: \(refreshedToken)")

// Connect to FCM since connection may have failed when attempted before having a token.

func connectToFcm() {
FIRMessaging.messaging().connect { (error) in
if (error != nil) {
print("Unable to connect with FCM. \(error)")
} else {
print("Connected to FCM.")

private func applicationDidEnterBackground(application: UIApplication) {
print("Disconnected from FCM.")

Answer Source

Just went through this,

I turned push off and deleted the certs from apple dev center and created them all over again and this made everything work as it should.

I also had this line of code set to,

FIRInstanceID.instanceID().setAPNSToken(deviceToken as Data, type: FIRInstanceIDAPNSTokenType.sandbox)

I will change it to .prod when I push to the app store.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download