我使用pushwoosh phonegap插件进行推送通知。成功注册后,我需要存储注册在“hwid”参数中使用的设备ID,以便我可以定位通过此相同设备ID发送的推送通知。这在Android上效果很好,因为它似乎是phonegap device.uuid是pushwoosh插件发送到其服务器的相同ID。但是,在ios上,device.uuid返回的ID不同于发送到pushwoosh的ID。我可以从Xcode控制台看到日志hwid插件发送pushwoosh,但无法弄清楚他们从哪里获取此ID以及如何在phonegap中访问相同的ID。Pushwoosh phonegap插件,检索设备ID
编辑:我希望getRemoveNotificationStatus函数会返回这个信息,但它实际上返回小于registerDevice回调。
更新:好的,通过挖掘他们的插件代码,我看他们在哪里构建这个ID,他们发送到他们的服务器。不知道为什么通过phonegap插件无法访问此ID,因为这是我最终需要具有的ID,以将推送通知定位到特定设备。
其代码:
(NSString *) uniqueDeviceIdentifier{
NSString *macaddress = [self macaddress];
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSString *stringToHash = [NSString stringWithFormat:@"%@%@",macaddress,bundleIdentifier];
NSString *uniqueIdentifier = [self stringFromMD5:stringToHash];
return uniqueIdentifier;
}
- (NSString *) uniqueGlobalDeviceIdentifier{
// >= iOS6 return identifierForVendor
UIDevice *device = [UIDevice currentDevice];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.1")) {
if ([device respondsToSelector:@selector(identifierForVendor)] && [NSUUID class]) {
NSUUID *uuid = [device identifierForVendor];
return [uuid UUIDString];
}
}
// Fallback on macaddress
NSString *macaddress = [self macaddress];
NSString *uniqueIdentifier = [self stringFromMD5:macaddress];
return uniqueIdentifier;
}
哦jeez,那完全是我的问题。我首先实现了Android插件,并成功使用phonegap的device.uuid进行了定位。然后,当我开始实施iOS插件时,我将相同的值传递给我的服务器而不是令牌,并且当我继续追踪追踪发送到pushwoosh的“hwid”值时。 – user2341060 2013-05-07 18:44:32