应用程序无效状态通知未到达?

时间:2016-01-06 04:44:26

标签: ios objective-c push-notification

当我的应用处于活动状态时,我使用alertview显示通知,当我的应用处于非活动状态时,我想显示通知。

这是我的回答:

aps =     {
        alert =         {
            calltype = order;
            id = 194;
            info = "Dear Customer Thank you for contacting SR number for your request is SACHA4 We will contact you shortly with our service professional details.";
        };
        sound = default;
    };

我正在拆分像这样的值:

NSDictionary *aps=[userInfo objectForKey:@"aps"];
    NSDictionary *alertdic=[aps objectForKey:@"alert"];

非活动状态编码:

if (application.applicationState == UIApplicationStateInactive)
    {

        query=[NSString stringWithFormat:@"insert into job ('id','message','calltype')values('%ld','%@','%@')",[[alertdic objectForKey:@"id"] integerValue],[alertdic objectForKey:@"info"],[alertdic objectForKey:@"calltype"]];

        UILocalNotification *notification = [[UILocalNotification alloc] init];
        notification.alertBody = [alertdic objectForKey:@"message"];
        notification.applicationIconBadgeNumber = 0;

        [[UIApplication sharedApplication] scheduleLocalNotification:notification];


    }

但是通知没有到达,但是通知声音到了。我需要你的帮助朋友。

2 个答案:

答案 0 :(得分:1)

如果您的应用程序位于Inactive status,那么您无法在此时向用户显示任何警告,系统通知中将向用户显示默认系统通知。因此,在处于停用状态时,您必须使用解析推送(或您使用的任何内容)注册您的应用程序,并且会发送用户通知,但是当用户点击该通知时,您可以检查此条件if (application.applicationState == UIApplicationStateInactive),在此您可以向用户显示提醒或重定向到任何特定页面。

答案 1 :(得分:0)

我的服务器响应这是我们之前的回复:

aps =     {
        alert =         {
            calltype = order;
            id = 194;
            info = "Dear Customer Thank you for contacting SR number for your request is SACHA4 We will contact you shortly with our service professional details.";
        };
        sound = default;
    }

现在我们将此更改为喜欢这个

aps =     {
        alert = "Dear Customer Thank you for contacting SR number for your request is SACHAS We will contact you shortly with our service professional details.";
        calltype = order;
        id = 194;
        sound = default;
    };