CocoaPods 是 Cocoa 项目的依赖管理工具。 您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 EZPush
集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target '<Your Target Name>' do
platform :ios, '13.0'
pod 'EZPush'
end
然后,运行以下命令
$ pod install
您可以使用 Swift Package Manager 将 EZPush 安装到您的 Xcode 项目中。 请按照以下步骤操作
https://github.com/ez-push/ios
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
application.registerForRemoteNotifications()
EZPush.current.registerPushNotificationDelegate() // EZPush must handle incoming notifications
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// TODO: store device token for EZ-Push initialization
}
要开始使用 EZPush,请将模块导入到您的 Swift 代码中
import EZPush
请求权限
EZPush.current.requestForPushNotificationPermission([.alert, .badge, .sound]) { _, _ in }
配置 EZPush
let config = EZPushConfiguration(licenseKey: "YOUR_LICENSE_KEY", showDebugInfo: true, groupName: "YOUR_GROUP_NAME")
EZPush.current.configure(config, startPeriodicSync: Bool)
EZPush.current.initialize(pushNotificationToken: "PUSH_NOTIFICATION_TOKEN") { _, _ in }
iOS Example.xcodeproj
和 EZPush.xcodeproj
中 Package Dependencies 的版本CoreVersion
文件中的版本