你最好的选择可能是修改设备插件(带有所有不希望的后果)。我能够在./cordova/platforms/ios/[project名称] /Plugins/org.apache.cordova.device/CDVDevice.m添加以下行deviceProperties
来获得设备名称:
- (NSDictionary*)deviceProperties
{
UIDevice* device = [UIDevice currentDevice];
NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
[devProps setObject:[device name] forKey:@"name"]; // <------------- new line
您还需要调整./cordova/plugins/org.apache.cordova.device/www/device.js相应的JavaScript对象:
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.name = info.name; // <---------- new line
device.name
可能已被弃用,从插件删除,但在iOS SDK 8.1 documentation中,分配的name
仍然是受支持的属性。
您是否能够正常工作? – sherb 2014-11-01 02:17:30