我遵循了firebase网站上的文档指南,完成了以下所有工作:
1.在AppDelegate.swift中实现了代码。
2.将豆荚添加到我的podfile中并安装。
3.在帐户中创建了Certifictes、标识符和概要文件中的APN身份验证密钥,并将其粘贴到developer.apple设置中。
4.在项目功能中启用了推送通知(检查了两个v)。
5.创建的证书类型: Apple服务用于生产
我从firebase控制台发送了两份通知,但在我的iPhone (IOS10.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
}发布于 2017-12-06 15:10:12
https://stackoverflow.com/questions/46392508
复制相似问题