Pergunta

Eu já consegui obter o deviceToken do APNS. É o tipo de nsdata. Então, eu quero escrever este Deviectoken no meu MySQL DB. Eu já tentei convertê -lo em uma string sem sorte. Esse foi o meu jeito:

 NSString *tokenTMP = [[NSString alloc] initWithData:devToken encoding:NSASCIIStringEncoding];

Se eu tiver o DeviceToken em um formato legível. Como uso o token no PHP para enviar uma solicitação ao servidor APNS?

Muito obrigado!

Foi útil?

Solução

Eu adicionei a seguinte categoria para nsdata

- (NSString*) stringWithHexBytes 
{
   NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([self length] * 2)];
   const unsigned char *dataBuffer = [self bytes];

   for (int i = 0; i < [self length]; ++i)
   {
       [stringBuffer appendFormat:@"%02X", (unsigned long)dataBuffer[ i ]];
   }

   return [[stringBuffer retain] autorelease];
}

Então eu posso chamar [DevToken StringWithHexbytes]; e envie -o para o meu servidor e guarde -o como texto.

Espero que ajude.

Chris.

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