[英]Firebase Push notifications not working ios11 swift 4.1
After updating my CellPhone and reinstalling the app, i got noticed that the push notifications were going through remoteMessage
methods and not by the didReceiveRemoteNotification
methods. 更新我的手机并重新安装应用程序后,我得到注意到,推送通知正在经历
remoteMessage
方法,而不是通过didReceiveRemoteNotification
方法。 After updating the firebase, the framework called nanopb
dissapeared and when i try to build the project, i'm facing the ld: framework not found nanopb clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried to set the pods like this: 更新
nanopb
消失了名为nanopb
的框架,当我尝试构建项目时,我ld: framework not found nanopb clang: error: linker command failed with exit code 1 (use -v to see invocation)
了ld: framework not found nanopb clang: error: linker command failed with exit code 1 (use -v to see invocation)
I试图像这样设置豆荚:
pod 'Firebase/Core', '4.0.3'
pod 'Firebase/Messaging', '4.0.3'
pod 'FirebaseInstanceID', '2.0.0'
According to this answer i tried to, but it is presented the same "not found" error. 根据这个答案,我尝试过,但是出现了同样的“未找到”错误。
I also have the notifications capability activated: 我还激活了通知功能:
My code in the appDelegate is: 我在appDelegate中的代码是:
let gcmMessageIDKey = "gcm.message_id"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = .lightContent
FirebaseApp.configure()
Messaging.messaging().delegate = self
Messaging.messaging().shouldEstablishDirectChannel = true
if #available(iOS 10.0, *) {
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()
NotificationCenter.default.addObserver(self, selector: #selector(self.tokenRefreshNotification), name: .InstanceIDTokenRefresh, object: nil)
if let token = Messaging.messaging().fcmToken{
print("FCM token: \(token)")
} else {
//will refresh in some method for later
}
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
completionHandler(UIBackgroundFetchResult.newData)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
}
There is a way to add the nanopb framework to my project or whats the necessary steps to workaround this problem? 有一种方法可以将nanopb框架添加到我的项目中,或者解决该问题的必要步骤是什么?
Thanks. 谢谢。
I opened my app today and it worked again... 我今天打开了我的应用程序,它再次起作用了...
Apparently it was a problem with the firebase... All my other apps didn't get any push notification for the whole day. 显然这是Firebase的问题...我所有其他应用全天都没有收到任何推送通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.