Shivani Sharma
Shivani Sharma

Reputation: 707

iOS Push Notifications is not received

Backend - Django

Frontend - Objective C (X-code)

I've followed this Apple Document to configure Push Notifications and successfully completed all steps.

For Backend, I am using django-push-notifications with Django==1.7 and it results into no error when message is sent.

For Frontend, I have added following lines to receive the notification,

    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |

                                                    UIUserNotificationTypeBadge |

                                                    UIUserNotificationTypeSound);

    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes

                                                                             categories:nil];

    [application registerUserNotificationSettings:settings];

    [application registerForRemoteNotifications];


- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

{

    NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]];

    token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];

    NSLog(@"content---%@", token);

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"DeviceToken!!!" message:token delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];

    [alert show];

}


- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

....   

}

But after this, I am not able to receive the notification. Have I completed and configured steps correctly? My X-code version is 6.3 and Apple Device with iOS version on 8.4. Should both be compatible versions to receive the notifications?

Is there any way to log or view the progress at APNs cloud?

Upvotes: 2

Views: 1118

Answers (2)

christijk
christijk

Reputation: 2213

  1. Check whether the device token are getting updated to your server.
  2. Check the mode of push operation. Development or Distribution? Provision your application based on that.
  3. Confirm that APNS service is enabled in your application and you are provisioned your app using that mobile provision.(In member center).
  4. Also check whether the .pem is proper or not?

If everything is proper, the try deleting the existing build, restart the phone and install new build and try.

Upvotes: 0

AlexZd
AlexZd

Reputation: 2152

Use deviceToken directly like

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
    NSLog(@"My token is: %@", deviceToken);
}

Also you need to be sure that you're sending Push-notification.

Try to use this tutorial and their application it will help you to be sure that you're sending Push correctly and you need to fix frontend.

Upvotes: 1

Related Questions