admin管理员组文章数量:1287649
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). 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.
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 3.0 iOS7 ApplicationPreferences Plugin
.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 mandline 'phonegap local plugin add htttps//github...' mand?
- the mandline option did not work. Is this because the github code is deprecated?
- 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>
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.
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). 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.
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:
https://github./phonegap/phonegap-plugins/tree/DEPRECATED/iOS/ApplicationPreferences
Phonegap 3.0 iOS7 ApplicationPreferences Plugin
https://developer.apple./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 mandline 'phonegap local plugin add htttps//github...' mand?
- the mandline option did not work. Is this because the github code is deprecated?
- 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>
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.
Share Improve this question edited May 23, 2017 at 11:45 CommunityBot 11 silver badge asked Mar 19, 2014 at 16:00 profoundWandererprofoundWanderer 7431 gold badge6 silver badges7 bronze badges 1- I've gotten this working very well with github./apla/me.apla.cordova.app-preferences but can't get the Settings.bundle added without opening the xcode project (a non-starter, as platforms/ is in gitignore). I will post an answer once I've finished. – David Souther Commented Sep 16, 2014 at 13:35
1 Answer
Reset to default 11To create a Settings bundle that will work without having to muck in platforms/ios/, create a local plugin in your project.
./src/ios/plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://cordova.apache/ns/plugins/1.0"
id=".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./</repo>
<platform name="ios">
<resource-file src="Settings.bundle" />
</platform>
</plugin>
In Xcode, open ./src/ios
, and create a new 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./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.</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
. It will say Installing ".dataonline.dolores.settings" for ios
.
Use me.apla.cordova.app-preferences to load those settings from 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");
Edit Switched from two <source-file>
s to one <resource-file>
本文标签: javascriptCordova Phonegap IOS App SettingsBundle PossibleStack Overflow
版权声明:本文标题:javascript - Cordova Phonegap IOS App Settings.Bundle Possible? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741316674a2371955.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论