IOS プラットフォーム上に構築した PhoneGap 3.0 アプリがあります。
didFinishLaunchingWithOptions
特定のユーザー エージェントをスプーフィングしようとするメソッドに、次の 2 行を追加しましたAppDelegate.m
(多数の SO の質問に目を通した後)。
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"my custom user agent", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
IOS シミュレーターでアプリを実行して検査するnavigator.userAgent
と、予想される「カスタム ユーザー エージェント」が出力として得られます。
リモート phonegap ビルドを実行し、iPhone でアプリを実行して検査するnavigator.userAgent
と、カスタムのユーザー エージェントではなく、標準の iPhone ユーザー エージェントが取得されます。
navigator.userAgent
シミュレータとデバイスで異なる出力が得られるのはなぜですか?
関連する SO の質問: