I am building a mobile app with PhoneGap and it will download a file from my server, where I have php. I am looking for a way to differentiate between my phonegap app and "every other browser" from the php. I know how to look for user agent string in php, my question is if there's a string (like "PhoneGap") that I'll have in the user agent on every platform (android, iphone, etc) or if there's a way to tell PhoneGap to use my custom user agent string.Optionally if there's an idea what could I do in order to serve these files when the PhoneGap FileTransfer asks for them, but not when another browser does, is welcome. I don't want to force the users to create an account if there's another way.
--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
+ (void)initialize {
NSString *systemVersionString = [[[UIDevice currentDevice] systemVersion] stringByReplacingOccurrencesOfString:@"." withString:@"_"];
NSDictionary *webkitDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"533.17.9", @"4_3_2",
@"534.46", @"5_0",
@"534.46", @"5_0_1",
nil, nil];
NSString *webkitVersionString = nil;
if ((webkitVersionString = [webkitDictionary objectForKey:systemVersionString]) == nil) {
webkitVersionString = [webkitDictionary objectForKey:@"4_3_2"];
}
NSString *uaString = [NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU OS %@ like Mac OS X) AppleWebKit/%@ (KHTML, like Gecko) Mobile/9A334 MyString/%@",
[[UIDevice currentDevice] model],
systemVersionString,
webkitVersionString,
SYMBOL_TO_NSSTRING(PG_VERSION)];
NSLog(@"UA = %@", uaString);
// Set user agent (the only problem is that we can't modify the User-Agent later in the program)
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:uaString, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[dictionary release];