CocoaPods 是 Cocoa 项目的依赖管理工具。您可以使用以下命令安装它
$ gem install cocoapods
建议使用 CocoaPods 1.3.1 或更高版本来构建 Pusher Beams。
要使用 CocoaPods 将 Pusher Beams 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
# Replace `<Your Target Name>` with your app's target name.
target '<Your Target Name>' do
pod 'PushNotifications', '~> 4.0.0'
end
然后,运行以下命令
$ pod install
Carthage 是一个去中心化的依赖管理器,它可以构建您的依赖项并为您提供二进制框架。
建议使用 Carthage 0.26.2 或更高版本来构建 Pusher Beams。
您可以使用 Homebrew 安装 Carthage,使用以下命令
$ brew update
$ brew install carthage
要使用 Carthage 将 Pusher Beams 集成到您的 Xcode 项目中,请在您的 Cartfile
中指定它
github "pusher/push-notifications-swift"
根据您要为其构建依赖项的平台,继续执行以下步骤
Swift Package Manager 是一个用于管理 Swift 代码分发的工具。它与 Swift 构建系统集成,以自动化下载、编译和链接依赖项的过程。
要使用 Swift Package Manager 将 Pusher Beams 集成到您的 Xcode 项目中,请在 Xcode 中选择 File
> Swift Packages
> Add Package Dependency...
并提供以下 URL
https://github.com/pusher/push-notifications-swift
要将 Pusher Beams 添加为您自己软件包的依赖项,请使用以下代码
dependencies: [
.package(url: "https://github.com/pusher/push-notifications-swift.git", from: "4.0.0")
]
我们现在要求您在使用库之前启动 beams,例如注册任何兴趣。这意味着以下代码将不再有效,并会在控制台中记录错误
try! PushNotifications.shared.addDeviceInterest("donuts")
PushNotifications.shared.start("YOUR_INSTANCE_ID")
您现在需要将其替换为以下代码
PushNotifications.shared.start("YOUR_INSTANCE_ID")
try! PushNotifications.shared.addDeviceInterest("donuts")
我们建议始终在 application didFinishLaunchingWithOptions
回调中调用 start。请注意,您仍然可以控制何时显示推送通知提示请求,start 不会调用此提示。
我们正在使用 Slather 在本地生成测试覆盖率报告,并在提交 pull request 时使用 Codecov。
通过运行以下命令创建静态 html 页面报告
slather coverage --html --scheme PushNotifications --workspace PushNotifications.xcworkspace/ PushNotifications/PushNotifications.xcodeproj/
打开 html 报告
open 'html/index.html'
Pusher Beams 由 Pusher 拥有和维护。
Pusher Beams 在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE。