iOS SDK 快速入门
通过这个快速简单的示例,开始使用 Pushwoosh iOS SDK。
前提条件
Anchor link to要将 Pushwoosh iOS SDK 集成到您的应用中,您将需要以下内容:
下载示例项目
Anchor link to从 GitHub 克隆示例项目:
git clone https://github.com/Pushwoosh/pushwoosh-ios-sample.git配置项目
Anchor link to-
Open the project in Xcode.
-
Add
https://github.com/Pushwoosh/Pushwoosh-XCFrameworkas Swift Package Dependency. -
Set the bundle identifier for the main target (PushwooshSampleApp) to match your Pushwoosh project (e.g.,
com.pushwoosh.PushwooshSampleApp). -
Use the same bundle identifier for the NotificationService target, appending
.NotificationService(e.g.,com.pushwoosh.PushwooshSampleApp.NotificationService). -
In
Info.plist, set the:Pushwoosh_APPIDkey to the Pushwoosh Application CodePushwoosh_API_TOKENkey to the Pushwoosh Device API Token
Important: Be sure to give the token access to the right app in your Pushwoosh Control Panel. Learn more
运行项目
Anchor link to- 构建并运行项目。
- 应用将有两个标签页:“Actions”和“Settings”。导航到 Settings 标签页。
- 点击 Register for Pushes 按钮。
- 授予推送通知权限。设备将注册到 Pushwoosh。
您应该会看到类似这样的日志条目:
Pushwoosh: Initializing application runtime[PW] BUNDLE ID: __YOUR_BUNDLE_ID__[PW] APP CODE: __YOUR_APP_CODE__[PW] PUSHWOOSH SDK VERSION: 6.7.13[PW] HWID: __YOUR_HWID__[PW] PUSH TOKEN: (null)[PW] [I] -[PWNotificationManagerCompatiOS10] NotificationCenter authorization granted: 1[PW] [I] -[PWPushNotificationsManagerCommon] Registered for push notifications: __YOUR_PUSH_TOKEN__您的设备现在已注册到 Pushwoosh。
发送推送通知
Anchor link to返回 Pushwoosh 控制面板,并向您注册的设备发送推送通知。
要了解更多信息,请参阅基本集成指南。