跳到内容

iOS SDK 快速入门

通过这个快速简单的示例,开始使用 Pushwoosh iOS SDK。

前提条件

Anchor link to

要将 Pushwoosh iOS SDK 集成到您的应用中,您将需要以下内容:

下载示例项目

Anchor link to

从 GitHub 克隆示例项目:

Terminal window
git clone https://github.com/Pushwoosh/pushwoosh-ios-sample.git

配置项目

Anchor link to
  1. Open the project in Xcode.

  2. Add https://github.com/Pushwoosh/Pushwoosh-XCFramework as Swift Package Dependency.

  3. Set the bundle identifier for the main target (PushwooshSampleApp) to match your Pushwoosh project (e.g., com.pushwoosh.PushwooshSampleApp).

  4. Use the same bundle identifier for the NotificationService target, appending .NotificationService (e.g., com.pushwoosh.PushwooshSampleApp.NotificationService).

  5. In Info.plist, set the:

Important: Be sure to give the token access to the right app in your Pushwoosh Control Panel. Learn more

运行项目

Anchor link to
  1. 构建并运行项目。
  2. 应用将有两个标签页:“Actions”和“Settings”。导航到 Settings 标签页。
  3. 点击 Register for Pushes 按钮。
  4. 授予推送通知权限。设备将注册到 Pushwoosh。

您应该会看到类似这样的日志条目:

Terminal window
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 控制面板,并向您注册的设备发送推送通知

要了解更多信息,请参阅基本集成指南