Pergunta

In my application i have added notification by storing the device id in server and using php i sending notification the problem is now device token is not storing in the server previously it was working f9 but not its not working.

Previously I was using different account now I'm accessing different account after setting the new account certification in my app is not working please tell where I'm wrong.

Notification code.

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {
       [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeNone)];
       return YES;
     }


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

    const char* data = [deviceToken bytes];
    NSMutableString * token = [NSMutableString string];

   for (int i = 0; i < [deviceToken length]; i++) {
        [token appendFormat:@"%02.2hhX", data[i]];
   }


    NSString *urlString = [NSString stringWithFormat:@"url?token=%@",token];

    NSURL *url = [[NSURL alloc] initWithString:urlString];
    NSLog(@"token %@",urlString);


    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
    NSLog(@"request %@ ",urlRequest);
    NSData *urlData;
    NSURLResponse *response;
    urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:nil];    
    NSLog(@"data %@",urlData);
    [self clearNotifications];   
 }

The above same code was working fine previously now its not working I'm not able to find solution why its not storing after i changing to new account please tell me how to resolve.

Thanks.

Foi útil?

Solução

Just for other people reading this question. We have narrowed down the issue by implementing

-(void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error

After that it turns out that the app was signed with wrong provisioning profile. Simple things like that are getting missed :)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top