ios - Azure 移动服务中 iOS APNS 通知的 Microsoft 示例有哪些不正确之处?

标签 ios objective-c azure azure-mobile-services

我是一名新的 Objective C 程序员,am following the directions here to set up push notification

当我添加以下“可选”代码时,出现错误,并且无法编译:

- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo {
    NSLog(@"%@", userInfo);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notification" message:
                          [[userInfo objectForKey:@"aps"] valueForKey:@”alert”] delegate:nil cancelButtonTitle:
                          @"OK" otherButtonTitles:nil, nil];
    [alert show];
}

错误是“程序中出现意外的“@””,位于此处 userInfo objectForKey:@"aps"

编写这段代码的正确方法是什么?

最佳答案

检查页面,我发现代码中有一个小错误:

[[userInfo objectForKey:@"aps"] valueForKey:@”alert”] 中,其中 @”alert” 应该是 @"alert “

(是不同的字符)

这应该足以消除错误。

- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo {
    NSLog(@"%@", userInfo);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notification" message:
                          [[userInfo objectForKey:@"aps"] valueForKey:@"alert"] delegate:nil cancelButtonTitle:
                          @"OK" otherButtonTitles:nil, nil];
    [alert show];
}

关于ios - Azure 移动服务中 iOS APNS 通知的 Microsoft 示例有哪些不正确之处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18560034/

相关文章:

ios - 是否可以重置/丢弃 Firebase Remote Config 获取的值?

ios - 证书固定在 swift 3/Alamofire 4 中停止工作?

ios - 登录时发生意外故障(基本错误代码 1100)

ios - UINavigationControllerDelegate 和 UIViewControllerAnimatedTransitioning 的问题

c# - 使用图形与 WPF 应用程序连接到 Azure AD api

ios - handleWatchKitExtensionRequest 限制

ios - NSData datawithcontentsofffile 返回 null

iphone - Objective-C:如何为iPhone和iPad定义CELL_CONTENT_WIDTH?

azure - 错误: Cannot bind parameter 'executionContext' to type ExecutionContext

azure - Service Fabric,我在哪里使用哪个证书?