I added quickblox to my app
In development mode, push notification system works well.
However, when i put my app in production mode, the backend system says the push was sent, but the push is not received.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[QBSettings setLogLevel:QBLogLevelDebug];
[QBSettings setApplicationID:kAppID];
[QBSettings setAuthorizationKey:kAuthorizationKey];
[QBSettings setAuthorizationSecret:kAuthorizationSecret];
[QBSettings setAccountKey:@kAccountKey];
[QBSettings useProductionEnvironmentForPushNotifications:NO];
//switch to production mode
#ifndef DEBUG
[QBSettings setLogLevel:QBLogLevelNothing];
[QBSettings useProductionEnvironmentForPushNotifications:YES];
#endif
return YES;
}
and then somewhere inside my app I have this code
-(void)sendPushMessage:(QBChatAbstractMessage *)absMessage toUser:(NSInteger)userId andDelegate:(NSObject<QBActionStatusDelegate>*)delegate{
NSString *fullName = [self fullName];
NSString *mesage;
if(fullName){
mesage =[NSString stringWithFormat:@"%@ says: %@",fullName, absMessage.text];
}else {
mesage = absMessage.text;
}
NSMutableDictionary *payload = [NSMutableDictionary dictionary];
NSMutableDictionary *aps = [NSMutableDictionary dictionary];
[aps setObject:@"default" forKey:QBMPushMessageSoundKey];
[aps setObject:mesage forKey:QBMPushMessageAlertKey];
[aps setObject:[self dictionaryRepresentation] forKey:@"user_info"];
[payload setObject:aps forKey:QBMPushMessageApsKey];
NSLog(@"payload:%@",payload);
QBMPushMessage *message = [[QBMPushMessage alloc] initWithPayload:payload];
[QBMessages TSendPush:message toUsers:[@(userId) stringValue] delegate:delegate];
}
in development environment this code works very well. I checked my production APNS certificate several times, deleted it, remade it, reinstalled it and nothing is working in production mode
I tried sending myself a production push notification from the admin page
and received this
and these are the users it was sent to
why ?
Do you test production pushes with AdHoc ipa builds?
If you test it with debug mode - it won't work
Read this topic quickblox makes the same token for development and production
I already wrote an answer how to make this work