如何在iPhone中以不同方式使用设备令牌? [英] How to use device tokens in different ways in iphone?

查看:105
本文介绍了如何在iPhone中以不同方式使用设备令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我将使用pushNotification。那么在那种情况下,我该如何以不同的方式使用设备令牌?

In my application i am going to use pushNotification. So in that case how can i use device tokens in different ways?

让我在这一方面做更多说明。

Let me elaborate more on this side.

每当我在那个时候运行我的应用程序时,都会生成设备令牌,如果我在同一设备上一次又一次地运行该应用程序,是否会生成同一设备令牌?

Whenever i run my application at that time Device token will be generated,if i go for running the application again and again in the same device than it will generate the same device token or not?

如果它将生成与Apple文档中所定义的设备令牌不同的设备令牌,它将如何在服务器端进行处理?
从客户端发送到服务器端到底需要什么(即设备令牌或其他参数),以及在服务器端具有相同类型的方案?

if it will generate the different Device tokens than as per the Apple Documentation how is it Handling at the server side.? what is exactly needed to send from client side (i.e. Device token or other parameters) to the server side and which type of scenario is having at the server side for the same?

如果有人有任何解决方案,代码段或任何有用的链接,将不胜感激。

if anybody having any solution or any code snippet or any useful link,which would be appreciated.

推荐答案

此处是一个示例,不一定是有效的代码:

Here is an example, not necessarily working code:

- (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];
}

这篇关于如何在iPhone中以不同方式使用设备令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆