gpt4 book ai didi

ios - Quickblox 'automatic push notifications for offline user' 不工作

转载 作者:行者123 更新时间:2023-11-29 12:26:32 25 4
gpt4 key购买 nike

我有以下场景。用户 A 在前台向用户 B 发送消息——这是有效的当应用程序处于后台时,从“消息”控制台向用户 B 发送推送通知——这是有效的

我想在应用程序处于后台时向用户 B 发送通知警报。我读到这是由 quickblox 自动完成的,但对我来说并没有发生。

我已按照 this link 上的说明进行操作

我在开发模式下使用“Starter”帐户。我们是否需要具有“服务器端历史记录”的帐户才能使用此功能?

编辑 1:澄清:我想发送“离线用户的自动推送通知”,而不是来自应用程序的通知。我还发送了链接中提到的“save_to_history”标志。

最佳答案

发送推送通知使用下面的代码

-(void)applicationDidEnterBackground:(UIApplication *)application
{
[self sendMessageNotification:@"Hello Push notification" :1234 ];
}

-(void)sendMessageNotification:(NSInteger)recipientID message:(NSString*)message
{
isSentPushNotification = YES;
//[self sendPushNotificationToUser:message ids:@"1" audioFileName:@"default"];

NSMutableDictionary *payload = [NSMutableDictionary dictionary];
NSMutableDictionary *aps = [NSMutableDictionary dictionary];
[aps setObject:@"default" forKey:QBMPushMessageSoundKey];
[aps setObject:message forKey:QBMPushMessageAlertKey];
[aps setObject:@"1" forKey:QBMPushMessageAlertLocArgsKey];
[payload setObject:aps forKey:QBMPushMessageApsKey];
QBMPushMessage *pushMessage = [[QBMPushMessage alloc] initWithPayload:payload];
// Send push to users with ids 292,300,1395
[QBRequest sendPush:pushMessage toUsers:[NSString stringWithFormat:@"%lu",(long)recipientID]successBlock:^(QBResponse *response, QBMEvent *event) {
NSLog(@"Successfully dilivered push notification");
} errorBlock:^(QBError *error) {
NSLog(@"Fail to diliver push notification %@",error);

}];
}

但是您应该先订阅用户以接收推送通知

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Register subscription with device token
[QBRequest registerSubscriptionForDeviceToken:deviceToken successBlock:^(QBResponse *response, NSArray *subscriptions) {
// Registration succeded
} errorBlock:^(QBError *error) {
// Handle error
}];
}

更多详情请查看this

关于ios - Quickblox 'automatic push notifications for offline user' 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28940735/

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