gpt4 book ai didi

iOS 推送通知不播放声音且不显示角标(Badge)警报 [在 Objective C 中]

转载 作者:行者123 更新时间:2023-11-29 00:53:41 25 4
gpt4 key购买 nike

我使用的是此处提供的演示说明: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/

主要代码如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIUserNotificationType types = (UIUserNotificationType) (UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert);


UIUserNotificationSettings *mySettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

return YES;
}

-(void)MessageBox:(NSString *)title message:(NSString *)messageText
{
// OLD way of sending push notifications:

// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:messageText delegate:self
// cancelButtonTitle:@"OK" otherButtonTitles: nil];
// [alert show];


UIAlertController* alert= [UIAlertController
alertControllerWithTitle:title
message:messageText
preferredStyle:UIAlertControllerStyleAlert];


UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];

}

我收到通知,但没有声音和角标(Badge)更新。有什么建议吗?

最佳答案

您是否在 JSON 负载中包含了角标(Badge)和声音参数?

示例

{"aps":{"alert":"Example notification title","badge":1,"sound":"default"}}

我读过 Apple Push Notification Payload Documents熟悉一下自己。

关于iOS 推送通知不播放声音且不显示角标(Badge)警报 [在 Objective C 中],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37838043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com