我正在为移动设备开发基于位置的问答 SDK。
当询问有关特定位置的问题时,服务器端会定位最相关的用户并将问题发送给该用户。如果用户未能回答,问题将发送给第二好的用户,依此类推。
问题是我的 SDK 可能安装在设备上的多个应用程序上,这意味着用户可以多次收到问题。
有没有一种方法可以检测我的 SDK 是否安装在多个应用程序上?我认为将 UDID 发送到服务器可能会起作用,但是iOS UDID 因应用程序而异 https://stackoverflow.com/a/23109828/51197.
您可以使用 UIPasteboard 在设备上的应用程序之间共享数据。
UIPasteboard 类使应用程序能够在应用程序内以及与另一个应用程序共享数据。要与任何其他应用程序共享数据,您可以使用系统范围的粘贴板;要与与您的应用程序具有相同团队 ID 的其他应用程序共享数据,您可以使用特定于应用程序的粘贴板。
在您的 SDK 中,执行如下操作:
@interface SDKDetector : NSObject
@end
@implementation SDKDetector
+ (void)load
{
int numberOfApps = (int)[self numberOfAppsInDeviceUsingSDK];
NSLog(@"Number of apps using sdk:%d", numberOfApps);
}
+ (NSInteger)numberOfAppsInDeviceUsingSDK
{
static NSString *pasteboardType = @"mySDKPasteboardUniqueKey";
NSData *value = [[UIPasteboard generalPasteboard] valueForPasteboardType:pasteboardType];
NSMutableArray *storedData = [[NSKeyedUnarchiver unarchiveObjectWithData:value] mutableCopy];
if (!storedData) {
storedData = [NSMutableArray new];
}
NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier];
if (![storedData containsObject:bundleId]) {
[storedData addObject:[[NSBundle mainBundle] bundleIdentifier]];
}
value = [NSKeyedArchiver archivedDataWithRootObject:storedData];
[[UIPasteboard generalPasteboard] setData:value forPasteboardType:pasteboardType];
return [storedData count];
}
@end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)