SORU
21 ŞUBAT 2012, Salı


Nasıl bir NSString içine cihazım token (bilimsel deneyler bazen büyük) dönüştürebilirsiniz?

Push bildirimleri başlatıyorum. Bir Dize olarak benim APNS Token kaydetmek istiyorum.

- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken
{
    NSString *tokenString = [NSString stringWithUTF8String:[newDeviceToken bytes]]; //[[NSString alloc]initWithData:newDeviceToken encoding:NSUTF8StringEncoding];
    NSLog(@"%@", tokenString);
    NSLog(@"%@", newDeviceToken);
}

Kodun ilk satırı boş yazdırır. ikinci belirteç yazdırır. Nasıl bir NSString olarak benim newDeviceToken alabilir miyim?

CEVAP
21 ŞUBAT 2012, Salı


Biri bana bu konuda Yardım etti.Sadece birlikte geçen biriyim

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

const unsigned *tokenBytes = [deviceToken bytes];
NSString *hexToken = [NSString stringWithFormat:@"xxxxxxxx",
                      ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
                      ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
                      ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
[[MyModel sharedModel] setApnsToken:hexToken];

}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Mary Jane Tauyan

    Mary Jane Ta

    20 AĞUSTOS 2009
  • SuperPrincessjo

    SuperPrinces

    1 EKİM 2010
  • Warner Bros. UK

    Warner Bros.

    6 HAZİRAN 2008