本文介绍了Cordova Phonegap IOS App Settings.Bundle可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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:

不幸的是,我没有足够的经验来做到这一点:/我希望一个有经验的乐于助人的兽医可以更明确地说出来并指出我正确的方向:

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:


  • 我是否只需要.h,.m和.js文件并将它们分别放在'plugins'和'www'目录中,或者我是否必须使用命令行'phonegap local plugin add htttps // github ...'命令?


    • 命令行选项不起作用。这是因为github代码已被弃用吗?

    对不起所有漫长的菜鸟混乱..我只是因为我的生活不能找到一个易于理解的指南,了解如何在线任何地方执行此操作。我相信在我之后会有很多人有这些相同的问题,所以我非常感谢你的帮助。非常感谢。

    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.

    推荐答案

    要创建一个可以在平台/ ios /中无需工作的设置包,请创建一个本地插件在你的项目中。

    To 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.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 ,和

    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.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插件添加./src/ IOS 。它会说为ios安装com.dataonline.dolores.settings

    At the root of your project, run cordova plugin add ./src/ios. It will say Installing "com.dataonline.dolores.settings" for ios.

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

    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");
    

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

    这篇关于Cordova Phonegap IOS App Settings.Bundle可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:13