我正在使用wcsession在watch 2.0中开发一个项目。 我的可操作通知有两种类型的接受和拒绝按钮。当我点击接受或拒绝ActionWithIdentifier时,我的委托方法不会被调用。
我在extensiondeleget.m中使用此委托
1.- (void)handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)remoteNotification
{
dicPlayLoad=remoteNotification;
self.strActionNotificationType = identifier;
[self notification:identifier withDic:remoteNotification];
}
2.- (void)handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)remoteNotification withResponseInfo:(NSDictionary *)responseInfo
{
dicPlayLoad=remoteNotification;
self.strActionNotificationType = identifier;
[self notification:identifier withDic:responseInfo];
}
-(void)notification:(NSString *)strIdentifier withDic:(NSDictionary *)dic
{
self.strActionNotificationType = @"";
if ([strIdentifier isEqualToString:ACCEPT_IDENTIFIER])
{
NSDictionary *apsInfo = [dic objectForKey:@"aps"];
self.strStrRequestId = [apsInfo objectForKey:@"REQUEST_ID"];
self.strActionNotificationType = ACCEPT_PAYMENT_IDENTIFIER;
[self showAlertWithStyle:WKAlertControllerStyleAlert message:EXTENSION_DELGATE.strStrRequestId title:@"Alert"];
}
else if ([strIdentifier isEqualToString:REJECT_IDENTIFIER])
{
// do action for reject payment
NSDictionary *apsInfo = [dic objectForKey:@"aps"];
self.strActionNotificationType =isEqualToString:REJECT_IDENTIFIER;
// do action for accept payment
[self showAlertWithStyle:WKAlertControllerStyleAlert message:EXTENSION_DELGATE.strStrRequestId title:@"Alert"];
}
}
但是当我在警报视图中显示我的strIdentifier时,它显示空字符串。