首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IOS应用程序中的防火墙云消息传递(FCM)无法工作

IOS应用程序中的防火墙云消息传递(FCM)无法工作
EN

Stack Overflow用户
提问于 2017-09-24 16:53:42
回答 1查看 1.5K关注 0票数 1

我遵循了firebase网站上的文档指南,完成了以下所有工作:

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

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

3.在帐户中创建了Certifictes、标识符和概要文件中的APN身份验证密钥,并将其粘贴到developer.apple设置中。

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

5.创建的证书类型: Apple服务用于生产

我从firebase控制台发送了两份通知,但在我的iPhone (IOS10.3)中没有收到任何通知。有什么窍门要查吗?我错过了什么?

Podfile

代码语言:javascript
复制
  use_frameworks!

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

AppDelegate.swift

代码语言:javascript
复制
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
    }
EN

回答 1

Stack Overflow用户

发布于 2017-12-06 15:10:12

你必须增加一些方法。

只需将您的AppDelegate.swift与这一个比较:)

这是消防员的“官方”样本(我想是这样的)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46392508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档