简体   繁体   English

Cordova Phonegap IOS App Settings.Bundle可能吗?

[英]Cordova Phonegap IOS App Settings.Bundle Possible?

So I'm new to mobile development but I'm close to finishing up my first IOS application using HTML/CSS/JS and Cordova PhoneGap 3. I am trying to allow the user to provide text input through the iPhone's native "Settings" app (gray gear icon). 所以我是移动开发的新手,但我接近使用HTML / CSS / JS和Cordova PhoneGap 3完成我的第一个IOS应用程序。我试图允许用户通过iPhone的原生“设置”应用程序提供文本输入(灰色齿轮图标)。 My app will have have its own settings section within the "Settings" app where the user can input a specific IP address, that my app will then use. 我的应用程序将在“设置”应用程序中拥有自己的设置部分,用户可以在其中输入特定的IP地址,然后我的应用程序将使用该地址。

What I've found out so far is that I may need to install a PhoneGap plugin and need to add a settings.bundle root.plist file: 到目前为止我发现的是我可能需要安装PhoneGap插件并需要添加settings.bundle root.plist文件:

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

Phonegap 3.0 iOS7 ApplicationPreferences Plugin Phonegap 3.0 iOS7 ApplicationPreferences插件

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

Unfortunately i'm not experienced enough to make due with just this :/ I was hoping a helpful vet with more experience can spell it out a little clearer and point me in the right direction: 不幸的是,我没有足够的经验来做到这一点:/我希望有经验的有用兽医可以更清楚地说出来并指出我正确的方向:

  • Do I just take the .h, .m, and .js files and put them in the 'plugins' and 'www' directories respectfully, or do I have to use the commandline 'phonegap local plugin add htttps//github...' command? 我只是把.h,.m和.js文件放在'plugins'和'www'目录中,或者我必须使用命令行'phonegap local plugin add htttps // github ... '命令?
    • the commandline option did not work. 命令行选项不起作用。 Is this because the github code is deprecated? 这是因为github代码已弃用了吗?
  • How do I "reference the plugin in my app"? 我如何“在我的应用程序中引用插件”? is it just adding this extra line to my index.html page's body or is there more to it?: <script type="text/javascript" src="applicationPreferences.js"></script> 它只是将这个额外的行添加到我的index.html页面的正文中还是有更多内容?: <script type="text/javascript" src="applicationPreferences.js"></script>

Sorry for all the longwinded rookie confusion.. I just for the life of me could not find a easy-to-understand guide on how to do this anywhere online. 对不起所有漫长的新手混乱..我只是为了我的生活找不到一个易于理解的指南,如何在网上任何地方这样做。 I'm sure there will be plenty after me that have these same questions so I really appreciate the help. 我相信在我之后会有很多有这些相同问题的人,所以我非常感谢你的帮助。 Thanks much. 非常感谢。

To create a Settings bundle that will work without having to muck in platforms/ios/, create a local plugin in your project. 要创建一个可以在平台/ ios /中使用而无需工作的设置包,请在项目中创建一个本地插件。

./src/ios/plugin.xml ./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>

In Xcode, open ./src/ios , and create a new Settings.bundle 在Xcode中,打开./src/ios ,然后创建一个新的Settings.bundle

./src/ios/Settings.bundle/Root.plist ./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>

At the root of your project, run cordova plugin add ./src/ios . 在项目的根目录下,运行cordova plugin add ./src/ios It will say Installing "com.dataonline.dolores.settings" for ios . 它会说Installing "com.dataonline.dolores.settings" for ios

Use me.apla.cordova.app-preferences to load those settings from Javascript. 使用me.apla.cordova.app-preferences从Javascript加载这些设置。

./src/client/preferences.js ./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");

Edit Switched from two <source-file> s to one <resource-file> 编辑从两个<source-file>切换到一个<resource-file>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在PhoneGap中使用JavaScript创建和使用iOS settings.bundle值 - Creating and using iOS settings.bundle values with JavaScript in PhoneGap phonegap应用程序中的ios隐私设置 - ios privacy settings in phonegap app 是否可以在Phonegap / Cordova应用程序中生成数字签名? - Is it possible to generate digital signatures in Phonegap/Cordova App? 为Phonegap / Cordova iOS应用程序强制实现正确的方向横向模式 - Enforce right orientation landscape mode for Phonegap/Cordova iOS app 音频无法在 iOS Cordova Phonegap 应用中播放 - Audio won't play in iOS Cordova Phonegap app 使用Cordova Phonegap 3.3.0检查iOS应用程序上的互联网连接是否正常 - Check internet connection on iOS app with Cordova Phonegap 3.3.0 not working iOS cordova(phonegap)应用程序,JavaScript代码被完全阻止,冻结 - iOS cordova (phonegap) app, JavaScript code completely blocked, freezed iOS应用商店是否允许Phonegap / Cordova应用中的Javascript代码混淆? - Is Javascript code obfuscation allowed by the iOS App Store in Phonegap / Cordova apps? 在Phonegap(Cordova 2.9.0)iOS上进行地理位置定位 - geolocation on Phonegap (Cordova 2.9.0) iOS Cordova / PhoneGap和iOS会话持久性 - Cordova/PhoneGap and iOS Session Persistence
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM