【发布时间】:2017-11-07 02:52:41
【问题描述】:
您好,我正在尝试实现 google firebase 推送通知。
我正在使用 IOS 11 和 Xcode 9.0
Pod 文件
target 'VQ Smart Home' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for VQ Smart Home
pod 'SwiftyJSON'
pod 'NVActivityIndicatorView'
pod 'FirebaseInstanceID', '2.0.0'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
应用代理
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UINavigationBar.appearance().isTranslucent = true
/************************ FireBase Notification ************************************************************************/
FirebaseApp.configure()
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
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()
let token = Messaging.messaging().fcmToken
print("*********************************************************************************************************************")
print("FCM token: \(token ?? "")")
print("*********************************************************************************************************************")
/************************ FireBase Notification ************************************************************************/
return true
}
// Push Notification Methods
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")
}
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)
completionHandler(UIBackgroundFetchResult.newData)
}
错误
*********************************************************************************************************************
FCM token: dEukPynDndQ:APA91bG41IAmwarrpdqoUmYxQQ_a6Ro-13YycSXTTyrqRHDGnroJ0pI2cSS5XYIQJwL50s07zUJcaujuj7SY-F5jO_bVEkVpFFyz4jylmwAlgief65Cpl6_TSgNNXkd-eDse7p1uk_rE
*********************************************************************************************************************
- [BoringSSL] Function boringssl_context_get_peer_sct_list: line 1754 received sct extension length is less than sct data length
- [MC] Lazy loading NSBundle MobileCoreServices.framework
- [MC] Loaded MobileCoreServices.framework
- [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
- refreshPreferences: HangTracerEnabled: 0
- refreshPreferences: HangTracerDuration: 500
- refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
- [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40004000 started
- [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (URL)
- TIC Read Status [1:0x0]: 1:57
- TIC Read Status [1:0x0]: 1:57
我已向 Firebase 添加了正确的 APNs 密钥。仍然没有收到推送通知。有人可以帮我解决这个问题。 Tnx。
【问题讨论】:
标签: ios swift firebase push-notification