观看OS 2.0可操作的远程推送通知在Apple Watch上无效

时间:2015-11-09 18:52:36

标签: ios objective-c apple-push-notifications watchkit apple-watch

我正在使用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时,它显示空字符串。

0 个答案:

没有答案