Iphone – Push Notification is not working

apple-push-notificationsios-4.2iphonepush-notificationxcode

i edit and modify the provisioning profile alot of times. and i checked it in text editor too. everything is ok with provisioning profile. but still push notifications are not working. and i m getting this error. everyone is saying that its bcz of bad provisioning profile but my provisioning profile values are the same as Apple said in their documentation. i m getting this error:

Error in registration. Error: Error Domain=NSCocoaErrorDomain
Code=3000 "no valid 'aps-environment' entitlement string found for
application" UserInfo=0x127d80 {NSLocalizedDescription=no valid
'aps-environment' entitlement string found for application}

code lookes like this in my AppDelegate.m:

    - (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
                  [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |                       UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
                  [self.window addSubview:navigationController.view];
                  [self.window makeKeyAndVisible];
                  return YES;
       }
    -(void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken {
                 NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];
                 NSLog(@"DeviceTokenStr: %@",deviceTokenStr);
       }

Thanx for help in advance

Best Answer

I believe the "no valid 'aps-environment' entitlement string found for application" error appears when you don't sign your app with the correct provisioning profile. You'll have to generate a profile for your app as described in Mahesh's link). Also note that you can't use a team provisioning profile to sign an app that requires push notifications.