AppMetricaPush 类
- Instance methods
- Properties
- Method descriptions
- downloadAttachmentsForNotificationRequest:
- handleApplicationDidFinishLaunching(withOptions:)
- handleDidReceive(_:)
- handleRemoteNotification(_:)
- 处理场景将连接到会话(使用:connectionOptions)
- isNotificationRelated(toSDK:)
- setDeviceTokenFrom(_:)
- setDeviceTokenFrom(_:pushEnvironment:)
- setExtensionAppGroup(_:)
- userData(forNotification:)
- Property descriptions
处理推送通知的主要类。
Instance methods
|
在推送通知中上传附件。 该方法适用于 iOS 10.0 及更高版本。 |
|
|
处理来自方法 application(_:didFinishLaunchingWithOptions:) 的推送通知打开事件。 |
|
|
处理来自通知服务扩展的推送通知接收。 |
|
|
处理来自方法 application(_:didReceiveRemoteNotification:fetchCompletionHandler:) 的推送通知打开。 |
|
|
处理来自方法 scene(_:willConnectTo:options:) 的推送通知打开事件。 |
|
|
Returns |
|
|
为应用的生产环境注册设备令牌。 |
|
|
将应用程序的设备令牌注册到指定环境中。 |
|
|
为应用和通知服务扩展注册共享的 App Groups。 |
|
|
返回在推送通知中传递的任意数据字符串。 |
Properties
|
返回一个代理 UserNotificationCenterDelegate,用于处理 iOS 10 及更高版本的前台推送通知。 |
|
|
返回一个委托 UserNotificationCenterHandling,用于手动处理 iOS 10 及更高版本的前台推送通知。 |
Method descriptions
downloadAttachmentsForNotificationRequest:
class func downloadAttachments(request: UNNotificationRequest, callback: AttachmentsDownloadCallback)
在推送通知中上传附件。 该方法适用于 iOS 10.0 及更高版本。
参数:
|
|
|
|
|
上传通知内容的回调块。 Format:
包括一个 |
handleApplicationDidFinishLaunching(withOptions:)
class func handleApplicationDidFinishLaunching(withOptions launchOptions: [AnyHashable : Any]?)
处理来自方法 application (_: didFinishLaunchingWithOptions:) 的推送通知打开事件。 应在 AppMetrica SDK 初始化后调用此方法。
参数:
|
|
参数以“键-值”对的形式提供,包含有关应用程序启动的信息。 |
handleDidReceive(_:)
class func handleDidReceive(_ request: UNNotificationRequest?)
处理来自通知服务扩展的推送通知接收。
你应该在 didReceive (_: withContentHandler:) 的实现中调用该方法。
参数:
|
|
handleRemoteNotification(_:)
class func handleRemoteNotification(_ userInfo: [AnyHashable : Any]?)
处理来自方法 application(_:didReceiveRemoteNotification:fetchCompletionHandler:) 的推送通知打开。该方法应在 AppMetrica SDK 初始化后调用。
参数:
|
|
推送通知的参数,以“键-值”对的形式由系统传输。 |
处理场景将连接到会话(使用:connectionOptions)
class func handleSceneWillConnectToSession(with: connectionOptions)
处理来自方法 scene(_:willConnectTo:options:) 的推送通知打开。 应在 AppMetrica SDK 初始化后调用此方法。
参数:
|
|
系统传输的连接参数的 UIScene.ConnectionOptions 类对象。 |
isNotificationRelated(toSDK:)
class func isNotificationRelated(toSDK userInfo: [AnyHashable : Any]?) -> Bool
Returns 是如果推送通知与AppMetrica相关。
参数:
|
|
推送通知的参数,以“键-值”对的形式由系统传输。 |
返回:
是— 如果推送通知与AppMetrica相关。否— 如果推送通知与 AppMetrica 无关。
setDeviceTokenFrom(_:)
class func setDeviceTokenFrom(_ data: Data?)
为应用程序的生产环境注册设备令牌。 应在 AppMetrica SDK 初始化后调用此方法。
参数:
|
|
应用程序的设备令牌。 如果你传递 |
setDeviceTokenFrom(_:pushEnvironment:)
class func setDeviceTokenFrom(_ data: Data?, pushEnvironment: AppMetricaPushEnvironment)
将应用程序的设备令牌注册到指定环境中。 应在 AppMetrica SDK 初始化后调用此方法。
注意
AppMetrica 允许您向 Sandbox APNs 发送推送通知。 但是,如果设备上运行了不同环境的应用版本(开发 和 生产),推送通知的处理可能会工作不正常。 为了避免这个问题,你可以为_开发_环境使用一个单独的测试 API 密钥。
参数:
|
|
应用程序的设备令牌。 如果你传递 |
|
|
APNs 应用环境。 |
setExtensionAppGroup(_:)
class func setExtensionAppGroup(_ appGroup: String?)
为应用和通知服务扩展注册共享的 App Groups。
需要注册才能跟踪推送通知的送达。 要了解更多信息,请查看配置推送通知统计收集。
参数:
|
|
共享App组的名称。 |
userData(forNotification:)
class func userData(forNotification userInfo: [AnyHashable : Any]?) -> String?
返回在推送通知中传递的任意数据字符串:
- 在从 AppMetrica 界面发送时的 附加数据 字段中。
- 在
数据字段中发送时使用Push API。
参数:
|
|
推送通知的参数,以“键值对”的形式由系统传输。 |
返回:
任意数据字符串。
Property descriptions
userNotificationCenterDelegate
var userNotificationCenterDelegate: UserNotificationCenterDelegate? { get }
返回一个代理 UserNotificationCenterDelegate,用于处理 iOS 10 及更高版本的前台推送通知。
要处理前台推送通知,请将此代码添加到 application(_:didFinishLaunchingWithOptions:) 方法中:
let delegate = AppMetricaPush.userNotificationCenterDelegate
UNUserNotificationCenter.current().delegate = delegate
要手动处理推送通知,请使用 userNotificationCenterHandler。
userNotificationCenterHandler
var userNotificationCenterHandler: UserNotificationCenterHandling? { get }
返回一个委托 UserNotificationCenterHandling,它允许你手动处理 iOS 10 及更高版本的前台推送通知。
使用此代理,如果你用自定义逻辑实现了UNUserNotificationCenterDelegate协议。 在这种情况下,您应该实现 UNUserNotificationCenterDelegate 代理的所有方法,并在 UserNotificationCenterHandling 中调用相应的方法。
为了简化推送通知处理,使用 userNotificationCenterDelegate。