MCDConnectedDevicesNotificationRegistrationManager

@interface MCDConnectedDevicesNotificationRegistrationManager : NSObject

管理所有帐户的连接设备平台云通知的注册。

MCDConnectedDevicesNotificationRegistrationManager 管理为每个帐户注册的通知信息。 每当应用的通知信息更改 (例如,当 APNS 更改其令牌) 或通知信息过期时,应用应重新注册其信息。 如果应用程序只关心对传出通信的响应,可以使用轮询注册。

注意

必须先注册通知信息,然后许多 ConnectedDevices 方案才能成功工作。

属性

registrationStateChanged

@property(nonatomic, readonly, nonnull) MCDEvent<MCDConnectedDevicesNotificationRegistrationManager*, MCDConnectedDevicesNotificationRegistrationStateChangedEventArgs*>* registrationStateChanged;

当帐户的通知注册状态发生更改时,让应用知道的事件。

方法

registerForAccountAsync

- (void) registerForAccountAsync:(MCDConnectedDevicesAccount* _Nonnull)account registration:(MCDConnectedDevicesNotificationRegistration* _Nonnull)notificationRegistration callback:(nonnull void (^)(BOOL, NSError* _Nullable))callback __attribute__((deprecated("Use registerAsync instead")));

使用给定的通知注册信息注册给定的帐户。 这会创建一个通知通道,以便可以通知此应用程序有关此帐户的新连接设备信息。 请注意,在发布 MCDRemoteSystemAppRegistration 信息之前,其他应用程序无法使用此通知通道与此应用通信。

警告

不推荐使用此函数。 请改用 registerAsync。

参数

  • account

要为其注册通知信息的帐户。

  • notificationRegistration

要注册的通知信息。

  • callback

如果注册成功完成,则为 的回调结果。

registerAsync

- (void) registerAsync:(MCDConnectedDevicesAccount* _Nonnull)account registration:(MCDConnectedDevicesNotificationRegistration* _Nonnull)notificationRegistration completion:(nonnull void (^)(MCDConnectedDevicesNotificationRegistrationResult* _Nonnull, NSError* _Nullable))callback;

使用给定的通知注册信息注册给定的帐户。 这会创建一个通知通道,以便可以通知此应用程序有关此帐户的新连接设备信息。 请注意,在发布 MCDRemoteSystemAppRegistration 信息之前,其他应用程序无法使用此通知通道与此应用通信。

参数

  • account

要为其注册通知信息的帐户。

  • notificationRegistration

要注册的通知信息。

  • callback

如果注册成功完成,则为 的回调结果。

getNotificationRegistrationStateForAccount

- (MCDConnectedDevicesNotificationRegistrationState) getNotificationRegistrationStateForAccount:(MCDConnectedDevicesAccount* _Nonnull)account;

检索给定帐户的当前通知注册状态。 如果应用卸载或长时间) 未运行,注册的通知信息最终将过期 (有用。 当注册过期/过期时,应用应重新注册其通知信息。

参数

  • account

要获取其注册状态的帐户。

返回

通知注册的状态。