【问题标题】:how to get Device Token using Iphone Application and other info about the device?如何使用 iPhone 应用程序和有关设备的其他信息获取设备令牌?
【发布时间】:2010-12-03 12:54:57
【问题描述】:

在我的 iphone 应用程序中,我想要使用 APN 的设备令牌。 如何使用代码获得它?

我还想要有关设备用户、其版本和其他信息的其他信息。 如何使用代码获得它?

是否可以使用Device Token获取设备其他信息?

Device Token 的格式是什么?

请通过代码或任何链接或任何其他方式给出解决方案,将不胜感激。

谢谢,

米沙尔·沙阿

【问题讨论】:

    标签: iphone device token


    【解决方案1】:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert ];
    }
    
    // Delegation methods 
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken: %@", deviceToken);
    } 
    

    【讨论】:

      【解决方案2】:

      您如何获取有关设备的信息---

      NSString*  deviceName= [[UIDevice currentDevice] uniqueIdentifier];
      NSString*  localizedModel=[[UIDevice currentDevice] localizedModel];
      NSString*  systemVersion=[[UIDevice currentDevice] systemVersion];
      NSString*  systemName=[[UIDevice currentDevice] systemName];
      NSString*  model=[[UIDevice currentDevice] model];
      

      【讨论】:

      • 是的,但它仍然必须与 APN 一起使用。来自 APN 的令牌可能会更改,您不能依靠它来为提供商识别您的设备。您应该获得唯一的 ID 和 APN 令牌 ID,并在注册时将它们发送给提供商。
      猜你喜欢
      • 1970-01-01
      • 2016-03-13
      • 2016-07-22
      • 1970-01-01
      • 2020-01-21
      • 2012-12-15
      • 2012-10-02
      • 1970-01-01
      相关资源
      最近更新 更多