Search code examples
iosobjective-cpush-notificationquickblox

Quickblox iOS Push notifications not working


In Quickblox iOS, the notifications don't work when I receive a chat message or send a push notification via code (it works with Parse though). The only way it works is when I send a Push notification on the Admin Panel selecting the "Testing"-Environment when the app is open or in background mode (not working when completely closed).

This is the code I use for sending a chat message via quickblox:

-(IBAction)sendMessage:(id)sender{
    NSString *messageText = self.messageTextField.text;
    if(messageText.length == 0){
        return;
    }

    QBChatMessage *message = [QBChatMessage message];
    message.text = messageText;
    message.markable = YES;
    message.dialogID = self.dialog.ID;
    NSString *senderLogin = [LocalStorageController shared].qbUser.login;
    NSMutableDictionary *senderLoginDictionary = [[NSMutableDictionary alloc]init];
    [senderLoginDictionary setObject:senderLogin forKey:@"senderName"];
    [message setCustomParameters:senderLoginDictionary];

    [[QMServicesManager instance].chatService sendMessage:message toDialog:self.dialog save:YES completion:nil];

    // clean text field
    [self.messageTextField setText:nil];
}

I have already submitted a ticket to quickblox but didn't receive any answer.


Solution

  • There is two ways to manage push notification in Quickblox:

    1. Automatic chat alerts (push notifications). Server will send push notifications to all offline users that corresponds to a specific chat dialog. Here is a documentation on how to set it up: http://quickblox.com/developers/Chat#Alerts

    2. Manual push notifications: you can send push notifications every time you send messages to a specific users. But keep in mind that all push notifications are platform based, and you need to send a universal pushes. There is a guide: http://quickblox.com/developers/SimpleSample-messages_users-ios#Send_Push_Notifications_from_application_.28via_API.29

    To set up APNS certificates follow this guide: http://quickblox.com/developers/SimpleSample-messages_users-ios