2014-07-23 60 views
0

我設置在用下面的代碼iOS的自定義用戶代理(didFinishLaunchingWithOptions):媒體不尊重用戶代理

// User agent 
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@「CustomAgent", @"UserAgent", nil]; 
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; 

這完全適用於所有的網絡請求。但是,當我創建一個var media = new Media(url); media.play();。它在仿真器中尊重它,但不在設備上。

從設備:

"Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D201 (341099536)」

從模擬器:

"Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D167CustomAgent (4474555984)」

https://github.com/apache/cordova-plugin-media/blob/master/src/ios/CDVSound.m#L393

回答

0

我能夠在CDVViewController重寫userAgent功能覆蓋用戶代理:

- (NSString*)userAgent 
{ 
    if (_userAgent == nil) { 
     //NSString* originalUserAgent = [CDVUserAgentUtil originalUserAgent]; 
     _userAgent = [NSString stringWithFormat:@"CustomAgent"]; 
    } 
    return _userAgent; 
}