0

I have followed this tutorial http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1

As notification has been sent successfully from the server as described in tutorial. But i am not getting it in my device.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    if(![[NSUserDefaults standardUserDefaults] valueForKey:@"UUID"])
    {
        if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
        {
            deviceID = [self GetUUID];
        }
        else
        {
            NSUUID* udid= [UIDevice currentDevice].identifierForVendor;
            deviceID = [udid UUIDString];
        }
        [[NSUserDefaults standardUserDefaults] setValue:deviceID forKey:@"UUID"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    else
    {
        deviceID = [[NSUserDefaults standardUserDefaults] valueForKey:@"UUID"];
    }

    return YES; }

- (NSString *)GetUUID {
        CFUUIDRef theUUID = CFUUIDCreate(NULL);
        CFStringRef string = CFUUIDCreateString(NULL, theUUID);
        CFRelease(theUUID);
        return (__bridge NSString *)string; }
David Wong
  • 10,284
  • 3
  • 39
  • 34
DipakSonara
  • 2,598
  • 3
  • 29
  • 34
  • UUID has nothing to do with delivering APNS - and your code does not show how you get your APNS token and if you send it to server and store it there somehow. David Wong's answer might point you to the right direction. Also check [this post](http://stackoverflow.com/q/19031862/653513) It is not exactly the same problem as yours but might offer some clarifications. – Rok Jarc Nov 02 '13 at 10:52
  • One tesed implementation of `didReceiveRemoteNotification:` can be found [here](http://stackoverflow.com/a/19348360/653513) – Rok Jarc Nov 02 '13 at 10:57
  • One more thing: if you have just created the APNS certificate(s) today you might simply need to wait for a couple of hours. – Rok Jarc Nov 02 '13 at 11:38

3 Answers3

1

Have you implemented application:didReceiveRemoteNotification: in your application delegate? When you're in app notifications get received there.

Or is it no notification gets sent to you?

Maulik
  • 19,348
  • 14
  • 82
  • 137
David Wong
  • 10,284
  • 3
  • 39
  • 34
1

For push notifications you have to register with the push notification token. iOS returns the push notification token with spaces, you have to remove them:

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

NSString *token = [[devToken description] stringByTrimmingCharactersInSet:      [NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"token: %@", token);
} 
Nikos M.
  • 13,685
  • 4
  • 47
  • 61
  • Yes i have done exactly according to the tutorial. Where they placed device token in .php file. And the problem is in receiving notification in device. – DipakSonara Nov 02 '13 at 11:26
  • Did you created the appropriate certificated and profiles in Apple Dev Portal? – Nikos M. Nov 02 '13 at 11:27
  • Yes, when i install the app first time it has asked me for enabling push notification service. – DipakSonara Nov 02 '13 at 11:41
  • That does not mean that the certificates are correct, it means just that you have added the push notification code in your app delegate. – Nikos M. Nov 02 '13 at 11:42
0

What's the size of your payload? The maximum length is 256bytes. If your payload is over that limit, it may say the push has been sent successfully yet Apple rejects it silently.

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

Ah Ryun Moon
  • 370
  • 5
  • 4