FireBase Remote notifications giving APS error when already implemented - ios

I'm pulling my hair out because I've triple checked and the following is True:
App delegate is setup (and now bloated)
APNs have been created signed and uploaded to apple downloaded keyed and uploaded to google
App has remote notifications toggled.
here is the app delegate:
import SwiftUI
import AVKit
import UIKit
import AVFoundation
import Firebase
import FirebaseMessaging
import UserNotifications
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSession.Category.playback)
} catch {
print("Audio session failed")
}
FirebaseApp.configure()
application.registerForRemoteNotifications()
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)
}
Messaging.messaging().delegate = self
UNUserNotificationCenter.current()
.requestAuthorization(options: [.alert, .sound, .badge]) {granted, error in
print("Permission granted: \(granted)")
}
UNUserNotificationCenter.current().delegate = self
application.registerForRemoteNotifications()
application.registerForRemoteNotifications()
Messaging.messaging().delegate = self
return true
}
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("FCM Token Is: \(fcmToken)")
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("Token is: \(deviceToken)")
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Error is \(error)")
}
// MARK: - UISceneSession
func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication,
didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
And the error log:
2020-10-07 12:25:57.235303-0500 Project[1428:310502] 6.34.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2020-10-07 12:25:57.249142-0500 Project[1428:310493] 6.34.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60900000 started
2020-10-07 12:25:57.249750-0500 Project[1428:310493] 6.34.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
Error is Error Domain=NSCocoaErrorDomain Code=3000 "no valid “aps-environment” entitlement string found for application" UserInfo={NSLocalizedDescription=no valid “aps-environment” entitlement string found for application}
2020-10-07 12:25:57.343208-0500 Project[1428:310500] 6.34.0 - [Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: no valid “aps-environment” entitlement string found for application
2020-10-07 12:25:57.350290-0500 Project[1428:310500] Metal API Validation Enabled
2020-10-07 12:25:57.476988-0500 Project[1428:310502] 6.34.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-10-07 12:25:57.477541-0500 Project[1428:310502] 6.34.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-10-07 12:25:57.477668-0500 Project[1428:310502] 6.34.0 - [Firebase/Analytics][I-ACS023220] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist

a simple update to Xcode 12.2 (beta 2) Command lines fixed the issue for whatever reason

I face with the same issue and after a few hours of research, I found the answer for my case.
In Target at Build Setting, find the key "CODE_SIGN_ENTITLEMENTS" and point it to the ".entitlements" file.

Related

APNS device token not set before retrieving FCM Token for Sender ID ''. Notifications to this FCM Token will not be delievered over APNS. - IOS

I am trying to enable push notifications using firebase and this is the document I referred. I followed everything till the end of step 4.
This is my PushNotificationManager.swift file
import Foundation
import FirebaseFirestore
import FirebaseMessaging
import UIKit
import UserNotifications
import FirebaseCore
class PushNotificationManager: NSObject, MessagingDelegate, UNUserNotificationCenterDelegate {
let userID: String
init(userID: String) {
self.userID = userID
super.init()
}
func registerForPushNotifications() {
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)
UIApplication.shared.registerUserNotificationSettings(settings)
}
UIApplication.shared.registerForRemoteNotifications()
updateFirestorePushTokenIfNeeded()
}
func updateFirestorePushTokenIfNeeded() {
if let token = Messaging.messaging().fcmToken {
let usersRef = Firestore.firestore().collection("users_table").document(userID)
usersRef.setData(["fcmToken": token], merge: true)
print(token)
}
}
// func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
// print(remoteMessage.appData)
// }
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
updateFirestorePushTokenIfNeeded()
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: #escaping () -> Void) {
print(response)
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("Registered for Apple Remote Notifications")
Messaging.messaging().setAPNSToken(deviceToken, type: .unknown)
}
}
This is the AppDelegate.m
mport UIKit
import FirebaseCore
import FirebaseAuth
import FirebaseFirestore
import FirebaseMessaging
#main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let db = Firestore.firestore()
let pushManager = PushNotificationManager(userID: "currently_logged_in_user_id")
pushManager.registerForPushNotifications()
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
application.registerForRemoteNotifications()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
Even though I am getting the FCM token printed as per the print statement in PushNotificationManager.swift. However I am getting the following in the console
APNS device token not set before retrieving FCM Token for Sender ID 'XXXXXXXXX'. Notifications to this FCM Token will not be delivered over APNS.Be sure to re-retrieve the FCM token once the APNS device token is set.
I have tried all the solutions mentioned on this post however I am not able to get past the error. Can someone tell me what I could be missing.

iOS Push Notifications doesn't work with Firebase

I use Firebase to send Notification with my iOS app, I have followed all step in documentation :
Apple Developer Account Configuration
Generating a CSR file
Uploading CSF file
Preparing the APNs Certificate
Configuring Firebase for Push Notifications
Building the Firebase Notification in my app
When I try to send a Notification there isn't no problem found in Firebase, for one particular user or for all iOS device. But none of my device (real device obviously) receive notification.
I use the good Bundle, I enable notification in my application and there is the code in my AppDelegate :
import UIKit
import UserNotifications
import Firebase
import FirebaseInstanceID
import FirebaseMessaging
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UINavigationBar.appearance().barTintColor = Design.blue_es
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white]
UINavigationBar.appearance().tintColor = UIColor.white
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().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
FirebaseApp.configure()
return true
}
func application(received remoteMessage: MessagingRemoteMessage) {
print(remoteMessage.appData)
}
// Called when APNs failed to register the device for push notifications
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
// Print the error to console (you should alert the user that registration failed)
print("APNs registration failed: \(error)")
}
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")
}
}
IN Swift 3
Configuring Your Apple Developer Account
Generating a CSR file
Uploading Your CSR File
Preparing the APNs Certificate
Configuring Firebase for Push Notifications
Building the Firebase Notification App
Installing the Firebase SDK Using CocoaPods
Adding GoogleService-Info.plist
Enabling Push Notifications
Initializing Push Notifications
AppDelegate of your Project
import UIKit
import SVProgressHUD
import UserNotifications
import Firebase
import FirebaseInstanceID
import FirebaseMessaging
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDelegate, MessagingDelegate {
var window: UIWindow?
static var appDelegate:AppDelegate!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: 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().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
FirebaseApp.configure()
return true
}
func application(received remoteMessage: MessagingRemoteMessage) {
print(remoteMessage.appData)
}
func application(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
Messaging.messaging().apnsToken = deviceToken as Data
}
}
I think first configure for firebase
FirebaseApp.configure()
after that you should call registerForRemoteNotifications()

Push notification retrieved in iOS but not in Firebase

I am facing this strange issue in my application. I am trying to integrate push notification in my application using firebase. I have included Firebase SDK in the project using the downloaded SDK(not using pod). I have included the following frameworks from the downloaded zip file in the application:
In 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")
}
The access token I get in didRegisterForRemoteNotificationsWithDeviceToken is valid and I successfully sent push to the device using that. But the didRefreshRegistrationToken of FireBase is not getting called. I have added -ObjC in linkerflags and FirebaseAppDelegateProxyEnabled as NO in info.plist. I have added the GoogleService-Info.plist file in the project root, and the project is configured correctly in FireBase console.
What is the possible issue here and how to solve it?
That was the silliest of mistakes while following the tutorials. Just needed to set the delegate of Messaging.messaging() as AppDelegate. Add the following code right under FirebaseApp.configure() and the issue is solved.
FirebaseApp.configure()
Messaging.messaging().delegate = self

Firebase Push Notification xcode console received notification but in device it is not working ios Objective c

I am using firebase for PushNotification but there is problem. The notification is received in xcode console not received in device. I am doing everything right but no success to get notification in device
2017-03-31 16:40:44.265 [7188] <Warning> [Firebase/Analytics][I-ACS003016] Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
2017-03-31 16:40:44.531 [7188] <Notice> [Firebase/Crash][I-CRA000004] Successfully initialized
2017-03-31 16:40:44.541: <FIRMessaging/INFO> FIRMessaging library version 1.2.2
2017-03-31 16:40:44.552 [7188:141393] *** -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
2017-03-31 16:40:44.666 [7188] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-03-31 16:40:44.758 [7188] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2017-03-31 16:40:45.124 [7188:141393] Unable to register for remote notifications: Error Domain=NSCocoaErrorDomain Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION" UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION}
2017-03-31 16:40:45.816 [7188:141393] Connected to FCM.
2017-03-31 16:40:45.920 [7188] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
Do you test on a physical, real device or on the simulator? On iOS Simulator you cannot register and receive push notifications :)
If you are working a on a real device, not the simulator, be reminded to call the following functions to register for push.
application.registerUserNotificationSettings(...)
Prior to the call:
https://developer.apple.com/reference/uikit/uiapplication/1623078-registerforremotenotifications
So altogether:
if application.respondsToSelector("registerUserNotificationSettings:") {
if #available(iOS 8.0, *) {
let types:UIUserNotificationType = ([.Alert, .Sound, .Badge])
let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
} else {
application.registerForRemoteNotificationTypes([.Alert, .Sound, .Badge])
}
}
else {
// Register for Push Notifications before iOS 8
application.registerForRemoteNotificationTypes([.Alert, .Sound, .Badge])
}
Some helpful debugging output could also be:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let pushSettings = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Badge ,UIUserNotificationType.Sound ,UIUserNotificationType.Alert], categories: nil)
application.registerUserNotificationSettings(pushSettings)
return true
}
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
application.registerForRemoteNotifications()
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let token=deviceToken.description
print(token)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(error)
}

iOS FCM not getting push notifications

Since i updated to swift 3, FCM doesn't work.
Push Notifications are enabled in Capabilities and Certificates are updated on Firebase console.
Btw, fcm on android app works just fine, and it was working on ios but after update on swift 3 and new firebase libraries, it doesn't.
AppDelegate.swift:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let notificationCenter = NotificationCenter.default
var connectedToFcm: Bool = false
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
FIRApp.configure()
NotificationCenter.default.addObserver(self, selector: #selector(self.tokenRefreshNotification), name: NSNotification.Name.firInstanceIDTokenRefresh, object: nil)
return true
}
func applicationDidEnterBackground(_ application: UIApplication) {
disconnectFromFcm()
}
func applicationDidBecomeActive(_ application: UIApplication) {
connectToFcm()
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("REGISTRED")
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: .unknown)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError
error: Error ) {
print("Registration for remote notification failed with error: \(error.localizedDescription)")
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
print(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
print(userInfo)
}
func tokenRefreshNotification(_ notification: Notification) {
let refreshedToken = FIRInstanceID.instanceID().token()
if refreshedToken != nil {
print("InstanceID token: \(refreshedToken!)")
// Connect to FCM since connection may have failed when attempted before having a token.
connectToFcm()
}
}
func connectToFcm() {
guard FIRInstanceID.instanceID().token() != nil else {
return;
}
if connectedToFcm == false {
FIRMessaging.messaging().disconnect()
FIRMessaging.messaging().connect { (error) in
if (error != nil) {
self.connectedToFcm = false
print("Unable to connect with FCM. \(error)")
} else {
self.connectedToFcm = true
print("Connected to FCM.")
self.sendTokenToServer()
}
}
return
}
}
func sendTokenToServer() {
let fcmToken = FIRInstanceID.instanceID().token()
if self.sharedUser.getToken().characters.count == 0 || fcmToken == nil {
return
}
let params = [
"reg_id": fcmToken!,
"dev_id": Config().devId
]
Alamofire.request(Config().fcmUrl, method: .post, parameters: params, encoding: JSONEncoding.default, headers: Config().apiHeaders)
.validate()
.responseJSON { response in
if response.result.isSuccess {
print("FCM token send to app server")
}
}
}
func disconnectFromFcm() {
FIRMessaging.messaging().disconnect()
connectedToFcm = false
print("Disconnected to FCM")
}
}
Log:
2016-12-22 09:26:34.921315 app[6198:1607437] Firebase automatic screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO in the Info.plist
2016-12-22 09:26:35.056527 app[6198:1607490] [Firebase/Core][I-COR000001] Configuring the default app.
2016-12-22 09:26:35.057: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-12-22 09:26:35.057 app[6198] <Debug> [Firebase/Core][I-COR000001] Configuring the default app.
2016-12-22 09:26:35.060: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-12-22 09:26:35.064: <FIRMessaging/INFO> FIRMessaging library version 1.2.0
2016-12-22 09:26:35.065598 app[6198:1607526] <FIRAnalytics/INFO> Firebase Analytics v.3501000 started
2016-12-22 09:26:35.067: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-12-22 09:26:35.067 app[6198:] <FIRAnalytics/INFO> Firebase Analytics v.3501000 started
2016-12-22 09:26:35.069638 app[6198:1607526] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2016-12-22 09:26:35.069 app[6198:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2016-12-22 09:26:35.073182 app[6198:1607488] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-12-22 09:26:35.073 app[6198:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-12-22 09:26:35.181355 app[6198:1607488] <FIRAnalytics/WARNING> The AdSupport Framework is not currently linked. Some features will not function properly.
2016-12-22 09:26:35.181 app[6198:] <FIRAnalytics/WARNING> The AdSupport Framework is not currently linked. Some features will not function properly.
2016-12-22 09:26:35.198981 app[6198:1607490] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-12-22 09:26:35.199 app[6198:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-12-22 09:26:35.285: <FIRInstanceID/WARNING> APNS Environment in profile: development
REGISTRED
2016-12-22 09:26:35.387693 app[6198:1607489] [Firebase/Core][I-COR000019] Clearcut post completed.
2016-12-22 09:26:35.387 app[6198] <Debug> [Firebase/Core][I-COR000019] Clearcut post completed.
Connected to FCM.
FCM token send to app server
I made prints to check if app gets token, and it does. Also, token is sent to server and i checked there if it is ok and if server is sending push.
I have faced same issue with iOS FCM integration I have solved it by using latest code for push notification in iOS 10.
You need to check the OS version of the device and segregate relevant codes.
if #available(iOS 10, *)
{
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if error == nil{
UIApplication.shared.registerForRemoteNotifications()
}
}
}else
{
// Register for remote notifications
if #available(iOS 8.0, *) {
// [START register_for_notifications]
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
// [END register_for_notifications]
} else {
// Fallback
let types: UIRemoteNotificationType = [.alert, .badge, .sound]
application.registerForRemoteNotifications(matching: types)
}
}
Put this code in a function and call it from did finish launching also comment your code.
Do let me know if you still have any issues.
Important :- import UserNotifications
Delegate :-
func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings)
{
/**
Allow device to register for remote notification.
*/
UIApplication.shared.registerForRemoteNotifications()
FIRMessaging.messaging().subscribe(toTopic: "/topics/test")
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
/**
Send device token to firebase to get the FCM token for pushnotification from firebase.
*/
FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.prod)
}

Resources