ios - 推送通知未发送,因为它在后台运行,parse.com

标签 ios objective-c multithreading parse-platform push-notification

我这里有问题,我真的不知道如何解决。

我正在使用此代码发送推送通知:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
  if(alertView == self.alert){

    if (buttonIndex == 1){


        // IF accepted was pressed, sent a notification to the requester
        NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
        [params setObject:self.senderChannel forKey:@"from"];

        [PFCloud callFunctionInBackground:@"sendAccepted" withParameters:params block:^(id object, NSError *error) {
            if (!error) {
                NSLog(@"Success answer sent");
            } else {
                NSLog(@"Failed to push");
            }

        }];
        .... rest of the code that opens another application on users Device

所以这里的问题是推送通知(我认为)没有完成运行并在后台发送,其他应用程序已启动,用户离开我的应用程序,导致推送通知未发送给用户。

我尝试删除打开另一个应用程序的代码,然后发送通知。感谢您提供各种帮助!

最佳答案

转到您的项目设置,

Section Capabilities

然后确保您已将后台模式切换为 -> ON,并在后台模式下确保您已切换后台获取远程通知,仅此而已。

关于ios - 推送通知未发送,因为它在后台运行,parse.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28126857/

相关文章:

ios - 有时登录需要很长时间

iOS 奇怪地读取一些字符?

java - 保证将成员变量值写入内存而不将其标记为 volatile

ios - 如何正确设置CABasicAnimation(开始)时间?

iphone - 有没有办法让应用程序代理运行条件,然后选择 Storyboard入口点?

ios - 调整 NSAttributedString 中使用的图像大小

objective-c - UIKit : [UIViewController mutableChildViewControllers] crash?

ios - 将 NSString 转换为 const char string[]

c# - 如何在 IList 上使用锁

java - 黑莓 - 线程没有响应