Jef*_*eff 1 database iphone url token push-notification
我们在我们的应用程序中添加了推送通知,但我们需要帮助将设备令牌发送到我们的数据库.截至目前我们已经建立了数据库,因此我们所要做的就是从NSLog获取设备令牌并将其放在数据库URL的末尾:http://www8.XXXXXXX.net/XXXXX_push/register.cfm ?token = TOKEN_HERE如果我们使用Safari,我们只需在URL栏中输入真实令牌,然后按Enter键,数据库就会收到令牌.我们说我们需要将代码放在App中:
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
Run Code Online (Sandbox Code Playgroud)
但我们只是不知道使用什么代码......因为我们真的很新.
有人可以告诉我们用什么代码发送我们制作的NSURL吗?
这是我们迄今为止所拥有的:
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *str = [NSString
stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(str);
NSString *fullURL = [NSString stringWithFormat:@"http://www8.xxxxxxxxx.net/xxxxx_push/register.cfm?token=%@",str];
NSURL *tokenURL = [NSURL URLWithString:fullURL];
Run Code Online (Sandbox Code Playgroud)
}
小智 5
didRegisterForRemoteNotificationsWithDeviceToken是您正在做的事情的正确位置.
我使用这个代码,借用urbanairship.com,清理deviceToken,然后通过NSURLConnection PUT将其发送回urbanairship服务器.
NSString *deviceToken = [[_deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""];
deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @">" withString: @""] ;
deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @" " withString: @""];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2236 次 |
| 最近记录: |