2

我已经从How to use device tokens in different ways in iphone? 中改编了这段代码?

- (void)sendProviderDeviceToken:(NSString *)tokenString {
NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];

NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

NSString *data = [NSString stringWithFormat:@"udid=%@&token=%@&id=%@&type=%i", udid, tokenString, bundleID, type];
NSString *escapedData = [[data description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSString *httpRequestURLString = [NSString stringWithFormat:@"http://%@/RegisterDevice.cgi?%@", kRegistrationURI, escapedData];
NSURL    *httpRequestURL       = [NSURL URLWithString:httpRequestURLString];
}

并且当设备连接时代码可以正常工作,但是一旦我断开设备,它就会停止工作。

显然我缺少一些东西,但并不明显

这是我在这里的第一个问题。我希望我遵循正确的形式......

4

0 回答 0