【问题标题】:Quickblox universal push notification not working.Quickblox 通用推送通知不起作用。
【发布时间】:2016-04-01 09:22:09
【问题描述】:

我正在为我的应用程序使用 quickblox。此应用程序适用于 android iOS。我正在处理推送通知。为此,我使用此代码:

// Send push to users with ids 292,300,1295
    QBMEvent *event = [QBMEvent event];
    event.notificationType = QBMNotificationTypePush;
    event.usersIDs = [NSString stringWithFormat:@"%ld", (long)recepID];
    event.type = QBMEventTypeOneShot;

    // standart parameters
    // read more about parameters formation http://quickblox.com/developers/Messages#Use_custom_parameters
    //
    NSMutableDictionary  *dictPush = [NSMutableDictionary  dictionary];
    [dictPush setObject:@"Message received from Bob" forKey:@"message"];
    [dictPush setObject:@"5" forKey:@"ios_badge"];
    [dictPush setObject:@"mysound.wav" forKey:@"ios_sound"];

    // custom params
    [dictPush setObject:@"234" forKey:@"user_id"];
    [dictPush setObject:@"144" forKey:@"thread_id"];

    NSError *error = nil;
    NSData *sendData = [NSJSONSerialization dataWithJSONObject:dictPush options:NSJSONWritingPrettyPrinted error:&error];
    NSString *jsonString = [[NSString alloc] initWithData:sendData encoding:NSUTF8StringEncoding];
    //
    event.message = jsonString;

    [QBRequest createEvent:event successBlock:^(QBResponse * _Nonnull response, NSArray<QBMEvent *> * _Nullable events)
    {
        // Successful response with event
        NSLog(@"Create event successfully to: %ld", (long)recepID);
    }
                errorBlock:^(QBResponse * _Nonnull response)
    {
        // Handle error
        NSLog(@"Create event error to: %@", response.error.description);
    }];

此创建事件失败并显示此错误:

Create event error to: 
   Error reasons:{
    errors =     (
        "No one can receive the message"
    );
}

所有设备都在订阅部分。仍然它给出错误。我从this quickblox document 复制了这段代码。请帮帮我。

【问题讨论】:

    标签: android ios push-notification quickblox


    【解决方案1】:

    通过在我的代码中添加这一行来解决它:

    event.isDevelopmentEnvironment = ![QBApplication sharedApplication].productionEnvironmentForPushesEnabled;
    

    【讨论】:

    • 仅供参考:您收到该错误是因为没有任何用户订阅,您想将推送发送到:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    相关资源
    最近更新 更多