انتقل إلى المحتوى

iOS SDK 7.0+ 快速入门

هذا المحتوى غير متوفر بلغتك بعد.

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

iOS SDK 7.0+ 的新功能

Anchor link to

从 7.0 版本开始,Pushwoosh iOS SDK 经过重新设计,采用了完全模块化的架构。该 SDK 现在分为多个独立的模块:PushwooshFrameworkPushwooshCorePushwooshBridgePushwooshLiveActivities 是基本集成所必需的,而 PushwooshForegroundPushPushwooshVoIPPushwooshTVOS 则可以根据您的需求选择性添加。

这种模块化的方法允许您只包含应用程序实际使用的功能,从而减小最终的二进制文件大小并缩短构建时间。每个模块都可以独立更新,从而更容易采用新功能,而不会影响集成的其余部分。

此版本引入了原生的 Swift Package Manager 支持,以便更轻松地进行依赖管理,同时改进了所有模块的 Swift 互操作性。文档现在直接嵌入到二进制框架中,因此您可以通过 Xcode 中的“快速帮助”和“开发者文档”窗口直接访问 API 参考和代码示例。新功能包括全面支持 iOS 16+ 的 Live Activities 与 Dynamic Island 集成、可自定义的带有动画横幅和触觉反馈的前台推送通知、增强的 VoIP 功能,以及一个专用于 Apple TV 应用程序的 tvOS 模块。

前提条件

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: 7.0.0
[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 控制面板,并向您注册的设备发送一条推送通知

从 SDK 6.x 迁移

Anchor link to

如果您从 SDK 6.x 版本升级,主要变化在于访问 Pushwoosh 实例的方式。在 7.0+ 版本中,请使用 Pushwoosh.configure 而不是 Pushwoosh.sharedInstance()

之前 (6.x):

Pushwoosh.sharedInstance().registerForPushNotifications()
Pushwoosh.sharedInstance().delegate = self

之后 (7.0+):

Pushwoosh.configure.registerForPushNotifications()
Pushwoosh.configure.delegate = self

所有其他 API 保持不变,因此更新您的代码只需在整个项目中将 sharedInstance() 替换为 configure 即可。

后续步骤

Anchor link to

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