Permalink
Browse files

Fix issue where user-agent was not being populated fully

  • Loading branch information...
1 parent 2b6b230 commit d421134c1b1009148c1e9c9aa35bb42fbfe27e0a Steve Streza committed Mar 7, 2013
Showing with 16 additions and 1 deletion.
  1. +16 −1 SDK/PocketAPI.m
View
@@ -561,6 +561,9 @@ -(NSString *)pkt_userAgent{
NSString *productName = @"PocketSDK:" POCKET_SDK_VERSION;
NSString *appName = [bundleInfo objectForKey:@"CFBundleDisplayName"];
+ if(!appName){
+ appName = [bundleInfo objectForKey:(NSString *)kCFBundleNameKey];
+ }
NSString *appVersion = [bundleInfo objectForKey:@"CFBundleVersion"];
NSString *deviceMfg = @"Apple";
NSString *storeName = @"App Store";
@@ -583,7 +586,19 @@ -(NSString *)pkt_userAgent{
}
#endif
- userAgent = [[[NSArray arrayWithObjects:productName,appName,appVersion,osType,osVersion,deviceMfg,deviceName,deviceType,storeName,nil] componentsJoinedByString:@";"] retain];
+#define PKTAtLeastEmptyString(__str) ((__str) == nil ? @"" : (__str))
+ userAgent = [[[NSArray arrayWithObjects:
+ PKTAtLeastEmptyString(productName),
+ PKTAtLeastEmptyString(appName),
+ PKTAtLeastEmptyString(appVersion),
+ PKTAtLeastEmptyString(osType),
+ PKTAtLeastEmptyString(osVersion),
+ PKTAtLeastEmptyString(deviceMfg),
+ PKTAtLeastEmptyString(deviceName),
+ PKTAtLeastEmptyString(deviceType),
+ PKTAtLeastEmptyString(storeName),
+ nil] componentsJoinedByString:@";"] retain];
+#undef PKTAtLeastEmptyString
}
return userAgent;
}

0 comments on commit d421134

Please sign in to comment.