gpt4 book ai didi

ios - IOS 应用程序中的 Firebase 云消息传递 (FCM) 无法正常工作

转载 作者:行者123 更新时间:2023-11-30 12:08:24 25 4
gpt4 key购买 nike

我按照 firebase 网站中的文档指南进行操作,并执行了以下所有操作:

1.实现了AppDelegate.swift中的代码。

2. 将 pod 添加到我的 podfile 中并安装。

3. 在证书、标识符和中创建 APN 身份验证 key 配置文件在我的developer.apple帐户中并将其粘贴到FCM设置中。

4.在项目功能中启用推送通知(选中两个 v)。

5. 创建的证书类型:用于生产的 Apple Push Services

我从 Firebase 控制台发送了几条通知,但在我的 iPhone (IOS 10.3) 中没有收到任何通知。 有什么建议可以检查吗?我错过了什么?

<小时/>

Podfile:

  use_frameworks!

# Pods for App
pod 'Firebase/Core'
pod 'Firebase/Crash'
pod 'Firebase/Messaging'

AppDelegate.swift:

import UIKit
import Firebase
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

var window: UIWindow?

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

// Use Firebase library to configure APIs.
FirebaseApp.configure()

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()


return true
}

最佳答案

您必须添加一些方法。

只需将您的 AppDelegate.swift 与 this one 进行比较即可:)

这是来自 firebase-guys 的“官方”样本(我想是的:D)

关于ios - IOS 应用程序中的 Firebase 云消息传递 (FCM) 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46392508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com