gpt4 book ai didi

ios - 从解析推送通知中提取消息的快速解决方案

转载 作者:行者123 更新时间:2023-11-29 01:52:52 27 4
gpt4 key购买 nike

下面的代码可以从线程(下面的链接)中找到,我似乎无法将其转化为快速解决方案,因为代码的缺陷似乎不是快速的直观修复(至少根据我的理解)。 ..

有人可以帮忙翻译这段代码吗,我需要能够快速从解析推送通知中读取消息(我相信这段代码可以在 objective-c 中完成)

Extract "alert" text from push notification

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
pushText = [userInfo objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"News", "")
message:pushText
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];

最佳答案

将此添加到您的 AppDelegate...

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
PFPush.handlePush(userInfo)
if let pushText = userInfo["alert"] as? String {
let title = NSLocalizedString("News",comment:"")
let alert = UIAlertView(title, message: pushText, delegate: nil, cancelButtonTitle: "Ok")
alert.show()
}
}

关于ios - 从解析推送通知中提取消息的快速解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31216311/

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