iphone - 需要帮助将带有设备 token 的 URL 从我们的 iPhone 应用程序发送到我们的数据库

标签 iphone database url push-notification token

我们向我们的应用程序添加了推送通知,但我们需要帮助将设备 token 发送到我们的数据库。截至目前,我们已经设置了数据库,所以我们所要做的就是从 NSLog 中获取设备 token 并将其放在数据库 URL 的末尾:http://www8.XXXXXXX.net/XXXXX_push/register.cfm ?token=TOKEN_HERE 如果我们使用 Safari,我们只需在 URL 栏中输入最后的真实 token ,然后按回车键,数据库就会收到 token 。 我们觉得我们需要将代码放在应用程序中:

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

但我们只是不知道要使用什么代码...因为我们对此真的很陌生。

有人可以告诉我们使用什么代码来发送我们制作的 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];

最佳答案

didRegisterForRemoteNotificationsWithDeviceToken 是您正在做的事情的正确位置。

我使用从 urbanairship.com 借用的这段代码来清理 deviceToken,然后通过 NSURLConnection PUT 将其发送回 urbanairship 服务器。

   NSString *deviceToken = [[_deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""];
    deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @">" withString: @""] ;
    deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @" " withString: @""];

关于iphone - 需要帮助将带有设备 token 的 URL 从我们的 iPhone 应用程序发送到我们的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5021642/

相关文章:

php - 使用 PHP 和 mysqli 从数据库中排除以前的值

mysql一对一消息优化表查询

有其他第三方库时iOS Frameworks : Ways to make this better,?

database - Cassandra - 合理的最大表数是多少?

iPhone:根据 Storyboard正确隐藏 UITableViewCell 中的附件按钮

php - 使用 .htaccess 重写 URL 以缩短链接

java - 替代已弃用的 javax.servlet.http.HttpUtils.parseQueryString?

python - 我如何使用python通过https下载pdf文件

ios - 在 Mapbox (iOS) 上将方向箭头添加到当前位置

iphone - (iphone)以编程方式 ScrollView 后强制调用scrollViewDidEndDecelerating?