EZPush SDK

菜单

要求

Swift 5 iOS 13.0+

文档

安装

CocoaPods

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

您可以使用 Swift Package Manager 将 EZPush 安装到您的 Xcode 项目中。 请按照以下步骤操作

  1. 在 Xcode 中打开您的项目。
  2. 选择“File” -> “Swift Packages” -> “Add Package Dependencies...”
  3. 输入此存储库的 URL:https://github.com/ez-push/ios
  4. 选择您想要使用的版本,然后单击“Add Package”。

使用

设置 App Delegate

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 }

贡献