Firebase Cloud Message iOS Swift无法正常工作 [英] Firebase Cloud Message iOS Swift not working
问题描述
我有两个iOS Swift应用.第一个已经存在于App Store中,假设它称为"ExistingStoreApp".我创建的第二个应用程序仅用于通过Firebase Cloud Messaging(FCM)测试推送通知,我将其称为"PushyTestApp".
我不明白的是:通过Firebase-Console发送推送通知->通知仅在PushyTestApp中有效,但不适用于ExistingStoreApp,尽管我在ExistingStoreApp上执行了相同的过程以使Firebase运行.我做了以下事情:
- 在Apple Dev中创建APNs AuthenticationKey.控制台( https://firebase.google.com/docs/cloud-messaging/ios/certs )
- 使用显式Bundle-ID创建App ID(此处ExistingStoreApp和PushyTestApp之间存在差异:ExistingStoreApp-App-ID已存在)
- 创建配置文件
- 创建应用(差异:ExistingStoreApp已经存在)
- 添加带有Pod"Firebase/Core"的CocoaPods&pod'Firebase/Messaging'-> pod install( https://firebase.google.com/docs/cloud-messaging/ios/client )
- 在Xcode应用程序功能中:推送通知处于打开状态,后台模式下的远程通知处于打开状态
- 使用现有的Firebase-Project(正在运行的Android)并添加新的iOS应用
- 将APN AuthKey上载到Firebase-Project-App
- 下载GoogleService-Info.plist->添加到XCODE源目录
- 使用示例代码( https填充AppDelegate.swift.://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExamapleSwift/AppDelegate.swift )
- 通过Firebase-Console发送消息,优先级:高
结果:PushyTestApp成功连接到Firebase,获得FCM-Token,在XCODE控制台中显示消息内容.ExistingStoreApp已成功连接到Firebase,使用Firebase-Console发送消息时获得了FCM-Token,无反应.
我没有禁用Method Sizzling.我错过了哪一部分?我以为这不是传统的Bundle-ID("My-Company.My-Appname"),而是与PushyTestApp一起使用的类似Bundle-ID.是因为ExistingStoreApp已经是分布式App,PushyTestApp还是开发中?
好吧,这是最奇怪的解决方案:放弃了几乎所有的战斗,我将包含Firebase的App-Update上传到了包含Firebase的App Store中.AppStore告诉我更新我的1024pt App-Icon.我进行了更改,在XCode的Media.xcassets中环顾四周,发现没有定义通知的图标.添加了它们,然后再次上传到App Store.
我上次尝试通过Firebase-Console和 bing 再次发送消息:在iPhone上收到的消息.无语.
希望有人在发疯之前先帮忙
I got two iOS Swift Apps. The first one already exists in the App Store, let's say it is called "ExistingStoreApp". The second App I created only to test Push-Notifications with Firebase Cloud Messaging (FCM), I call it "PushyTestApp".
What I do not understand: Sending Push-Notifications via Firebase-Console -> Notifications only works in PushyTestApp, but not with the ExistingStoreApp, although i did the same procedure on my ExistingStoreApp to make Firebase run. I did the following:
- Create APNs AuthenticationKey in Apple Dev. Console (https://firebase.google.com/docs/cloud-messaging/ios/certs)
- Create App ID with explicit Bundle-ID (Difference between ExistingStoreApp and PushyTestApp here: ExistingStoreApp-App-ID already exists)
- Create Provisioning-Profile
- Create App (difference: ExistingStoreApp already exists)
- Add CocoaPods with pod 'Firebase/Core' & pod 'Firebase/Messaging' -> pod install (https://firebase.google.com/docs/cloud-messaging/ios/client)
- In Xcode App-Capabilities: Push Notifications turn ON, Remote Notifications under Background Modes turn ON
- Use Existing Firebase-Project (Android running and working) and add new iOS App
- Upload APN AuthKey to Firebase-Project-App
- Download GoogleService-Info.plist -> Add to XCODE-Source dir
- Fill AppDelegate.swift with example Code (https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExamapleSwift/AppDelegate.swift)
- Send Message via Firebase-Console with priority: high
result: PushyTestApp connected successful to Firebase, got FCM-Token, shows Message-content in XCODE-console. ExistingStoreApp connected successful to Firebase, got FCM-Token, no reaction when sending message with Firebase-Console.
I did not disable Method Sizzling. Which part did I miss? I thought it would be the Bundle-ID which is not conventional ("My-Company.My-Appname") but a similar Bundle-ID worked with PushyTestApp. Is it because the ExistingStoreApp is already a distributed App, an PushyTestApp is Development?
Ok, here comes the most strangest solution: Giving almost up the fight, I uploaded my App-Update to the App-Store with Firebase in code included. The AppStore told me to update my 1024pt App-Icon. I changed it, looked around in my Media.xcassets in XCode and spotted, that I had no icons for notifications defined. Added them, uploaded again to App-Store.
I tried one last time to send again a msg over Firebase-Console and bing: Message received on iPhone. speechless.
Hope somebody helps this before going berserk
这篇关于Firebase Cloud Message iOS Swift无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!