Ios Parse.com:savenbackgroundithblock-未调用块
我正在使用最新版本的Parse iOS SKD(v1.4.2),并让我的应用程序真正为iOS 8做好准备 现在我遇到了以下问题: 如果用户订阅推送频道,我将使用Ios Parse.com:savenbackgroundithblock-未调用块,ios,push-notification,parse-platform,Ios,Push Notification,Parse Platform,我正在使用最新版本的Parse iOS SKD(v1.4.2),并让我的应用程序真正为iOS 8做好准备 现在我遇到了以下问题: 如果用户订阅推送频道,我将使用saveinbackgroundithblock方法在订阅成功后显示警报。 现在的问题是,从未调用成功的块 订阅将自动运行,没有任何问题-新频道将立即出现在Parse.com后端 所以我真的很困惑!;) 有没有人有同样的问题,特别是有解决办法 PFInstallation *currentInstallation = [PFIns
saveinbackgroundithblock
方法在订阅成功后显示警报。
现在的问题是,从未调用成功的块
订阅将自动运行,没有任何问题-新频道将立即出现在Parse.com后端
所以我真的很困惑!;)
有没有人有同样的问题,特别是有解决办法
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addUniqueObject:channel forKey:@"channels"];
[currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
// Show success Alert
UIAlertView *successAlert = [[UIAlertView alloc] initWithTitle:@"Success" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[successAlert show];
} else {
// Show error Alert
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[errorAlert show];
}
}];
更新:我玩了一下,注意到块被调用了,但我的警报没有显示…始终检查
成功的参数。与苹果的API一样,它只是节省了一点。我会这样做的。另外,由于您的目标是iOS8,我强烈建议您使用新的UIAlertController
API
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addUniqueObject:channel forKey:@"channels"];
[currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(@"%@", [error localizedDescription]); // DEBUG
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController* alert;
if (succeeded && !error) {
// Success Alert
alert = [UIAlertController alertControllerWithTitle:@"Success"
message:nil
preferredStyle:UIAlertControllerStyleAlert];
} else {
// Error Alert
alert = [UIAlertController alertControllerWithTitle:@"Error"
message:nil
preferredStyle:UIAlertControllerStyleAlert];
}
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
});
}];
你到底在做什么“显示成功警报”?部门?如果您正在执行任何UI任务(如UIAlertView),请确保在main上调度它queue@Paulw11我玩过它,我认为你是对的-如果我使用NSLog
它被称为。。。但UIAlertView未显示:/能否帮助我将其分配到主队列中<代码>UIAlertView*successAlert=[[UIAlertView alloc]initWithTitle:@“成功”消息:@“委托:自取消按钮:@“确定”其他按钮:无,无];[成功者秀]
@Paulw11我尝试了[自执行选择器onmainthread:@selector(pushSucces)with object:nil waitUntilDone:YES]代码>-但警报仍不显示:/I如果我还支持iOS 7,我需要警报的回退-对吗?对,UIAlertController
未进行后端口。我已成功使用