PushNotificationSimulation
PushNotificationSimulation
在应用开发过程中帮助模拟推送通知。
安装
使用Podfile 集成 Cocoapods
pod 'PushNotificationSimulation'
或者 Carthage 并向Cartfile
添加一行
github "pwlkania/PushNotificationSimulation"
或者在 Xcode 11 中使用 Swift Package Manager
File > Swift Packages > Add Package Dependency...
并添加以下内容:
[email protected]:pwlkania/PushNotificationSimulation.git
需求
iOS 11.0
初始化
修改您的 AppDelegate.swift
文件
(如需)导入 PushNotificationSimulation
框架
import PushNotificationSimulation
实现 PushNotificationSimulation
协议
#if DEBUG
extension AppDelegate: PushNotificationSimulation { }
#endif
用法
使用断点和调试命令进行调试(推荐方法)。
推送通知示例
sim(payload: "{\"aps\":{\"alert\":{\"title\":\"Game Request\",\"subtitle\":\"Five Card Draw\",\"body\":\"Bob wants to play poker\"},\"category\":\"GAME_INVITATION\"},\"gameID\":\"12345678\"}", delay: 3)
设备令牌示例
sim(deviceToken: "933e3112d1eae4a1d8eb48617a265b303be28b300193b9677f0ccf52a63a5b1e")
您还可以直接在代码中使用全局函数sim(payload: ...)
或sim(deviceToken: ...)
。但是,当您的应用程序的生产版本中的代码没有禁用时,可能会出现问题。请注意。
许可协议
该项目是在MIT 许可协议的条款下作为开源项目提供的。