cordova电话IOS应用程序Settings.Bundle可能吗?

所以我是新来的移动开发,但我接近完成我的第一个IOS应用程序使用HTML / CSS / JS和cordovaPhoneGap 3.我试图让用户提供通过iPhone本机“设置”应用程序的文本input(灰色齿轮图标)。 我的应用程序将在“设置”应用程序中有自己的设置部分,用户可以input特定的IP地址,然后我的应用程序将使用该部分。

到目前为止我发现的是,我可能需要安装一个PhoneGap插件,并需要添加一个settings.bundle root.plist文件:

https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/iOS/ApplicationPreferences

Phonegap 3.0 iOS7 ApplicationPreferences插件

https://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html

不幸的是,我没有足够的经验足以使这个:/我希望有更多经验的有益的兽医可以把它弄清楚一点,并指出我在正确的方向:

  • 我只是拿.h,.m和.js文件,把它们放在'plugins'和'www'目录中,或者我必须使用命令行'phonegap local plugin add htttps // github … '命令?
    • 命令行选项不起作用。 这是因为github代码已被弃用?
  • 我如何“在我的应用程序中引用插件”? 是只是将这个额外的行添加到我的index.html页面的正文,或者是有更多的?: <script type="text/javascript" src="applicationPreferences.js"></script>

对不起所有的新秀混乱..我只是为了我的生活找不到一个易于理解的指南,如何在网上任何地方做到这一点。 我相信在我之后会有很多这些相同的问题,所以我非常感谢帮助。 非常感谢。

要创build一个无需在平台/ ios /中工作的Settings捆绑包,可以在您的项目中创build一个本地插件。

./src/ios/plugin.xml

 <?xml version="1.0" encoding="UTF-8"?> <plugin xmlns="http://cordova.apache.org/ns/plugins/1.0" id="com.example.application.settings" version="0.4.2"> <name>Application Settings</name> <description>My Application's Default Settings</description> <license>Proprietary</license> <keywords>preferences, settings, default</keywords> <repo>https://github.com/</repo> <platform name="ios"> <resource-file src="Settings.bundle" /> </platform> </plugin> 

在Xcode中,打开./src/ios ,并创build一个新的Settings.bundle

./src/ios/Settings.bundle/Root.plist

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PreferenceSpecifiers</key> <array> <dict> <key>Title</key> <string>API Server</string> <key>Type</key> <string>PSGroupSpecifier</string> </dict> <dict> <key>AutocapitalizationType</key> <string>None</string> <key>AutocorrectionType</key> <string>No</string> <key>DefaultValue</key> <string>https://api.example.com</string> <key>IsSecure</key> <false/> <key>Key</key> <string>name_preference</string> <key>KeyboardType</key> <string>Alphabet</string> <key>Type</key> <string>PSTextFieldSpecifier</string> </dict> </array> <key>StringsTable</key> <string>Root</string> </dict> </plist> 

在项目的根目录下,运行cordova plugin add ./src/ios 。 它会Installing "com.dataonline.dolores.settings" for ios

使用me.apla.cordova.app-preferences从Javascript加载这些设置。

./src/client/preferences.js

 function ApplicationPreferences(){ var _this = this; this.server = window.location.origin; document.addEventListener('deviceready', function(){ function loaded(server){_this.server = server;} plugins.appPreferences.fetch(loaded, function(){}, 'api_server'); }); }; applicationPreferences = new ApplicationPreferences(); // Later.. $.get(applicationPreferences.server + "/api/data"); 

编辑从两个<source-file>切换到一个<resource-file>