1

全て、

ionic および phonegap ビルドを使用してみることにしました。プラグインを使ってみるまでは、すべてうまくいっていました。プラグインを呼び出そうとするとすぐに

プラグイン「デバイス」が見つからないか、CDVPlugin ではありません

weinre コンソールでは、

deviceready は 5 秒経過しても発火していません。チャネルが起動されていません: onCordovaInfoReady

プラグインが認識されていることをPhonegap Buildで確認できます.ipaファイルをダウンロードしてコンテンツを展開すると、すべてがそこにあることがわかります. 私は Phonegap の Ismael と一緒に働いていたので、これはイオンの問題ではないかと疑っています (非常に反応が良く、役に立つ、BTW)。彼は phonegap のサンプルを送ってくれました。彼の構成設定とコードに基づいて、私は同じものを実行していますが、まだ問題があります。誰かが私を助けることができれば、私はそれを大いに感謝します.

私がやった事

  1. sudo npm install ionic -g
  2. sudo npm install phonegap -g
  3. sudo npm install cordova -g
  4. sudo ionic start xxxx
  5. sudo ionic platform add ios
  6. CDxxxx
  7. CDwww
  8. phonegap リモートビルド iOS

環境

  • OS X 10.9.2
  • デバイス iOS 7.1 を実行している iPhone 4s
  • PhoneGap ビルド プロジェクト バージョン 3.3.0
  • ionic-v1.0.0-beta.1
  • phonegap CLI 3.4.0-0.19.8
  • コルドバ CLI 3.4.0-0.1.3

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.xxxx.xxxx" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>xxxxxxxx</name>
    <description>
        xxxx
    </description>
    <author email="xxxx@gmail.com">
        xxxx
    </author>
    <content src="index.html" />
    <access origin="*" />
    <preference name="phonegap-version" value="3.3.0" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <gap:plugin name="org.apache.cordova.device" />
    <gap:plugin name="org.apache.cordova.media" />
    <gap:plugin name="org.apache.cordova.media-capture" />
    <gap:plugin name="org.apache.cordova.file" />
</widget>

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>Ionic Seed App</title>

    <!-- ionic css -->
    <link href="lib/css/ionic.css" rel="stylesheet">

    <!-- your app's css -->
    <link href="css/app.css" rel="stylesheet">

    <!-- ionic/angularjs scripts -->
    <script src="lib/js/ionic.bundle.js"></script>

    <script src="lib/js/moment.min.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>
    <!-- your app's script -->
    <script src="js/app.js"></script>
    <script src="js/services.js"></script>
    <script src="js/controllers.js"></script>

  </head>

  <body ng-app="xxxx" animation="slide-left-right-ios7">

    <!--
      The nav bar that will be updated as we navigate between views
      Additional attributes set its look, ion-nav-bar animation and icons
      Icons provided by Ionicons: http://ionicons.com/
    -->
    <ion-nav-bar type="bar-positive"
             animation="nav-title-slide-ios7"
             back-button-type="button-icon button-clear"
             back-button-icon="ion-ios7-arrow-back"></ion-nav-bar>

    <!--
      The views will be rendered in the <ion-nav-view> directive below
      Templates are in the /templates folder (but you could also
      have templates inline in this html file if you'd like).
    -->
    <ion-nav-view></ion-nav-view>

  </body>
</html>    

app.js

var app = angular.module('xxxx', ['ionic', 'xxxx.services', 'xxxx.controllers']);

app.value('globals', {
    'ACSKey': 'xyz',
    'session_id': '',
    'logged_in_userId': ''
});

app.config(function($stateProvider, $urlRouterProvider) {

    // Ionic uses AngularUI Router which uses the concept of states
    // Learn more here: https://github.com/angular-ui/ui-router
    // Set up the various states which the app can be in.
    // Each state's controller can be found in controllers.js
    $stateProvider

    .state('login', {
        url: "/login",
        templateUrl: "templates/login.html",
        controller: 'LoginCtrl'
    })

    .state('register', {
        url: "/register",
        templateUrl: "templates/register.html",
        controller: 'RegisterCtrl'
    })

    // setup an abstract state for the tabs directive
    .state('tab', {
        url: "/tab",
        abstract: true,
        templateUrl: "templates/tabs.html"
    })

    .state('main', {
        url: "/main",
        templateUrl: "templates/main.html",
        controller: "MainCtrl"
    })

    .state('premise', {
        url: "/premise",
        templateUrl: "templates/premise.html",
        controller: "PremiseOfTheDayCtrl"
    })

    .state('friends', {
        url: "/friends",
        templateUrl: "templates/friends.html",
        controller: "FriendsCtrl"
    })

    .state('tab.about', {
        url: '/about',
        views: {
            'about-tab': {
                templateUrl: 'templates/about.html'
            }
        }
    });

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/login');

});

app.run(function($rootScope, $location, $ionicPlatform) {

    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() {
        alert('deviceready');
    }

    // $ionicPlatform.ready(function() {
    //     // Initialize plugin here
    //     console.log('ionicPlatform.ready');
    // });

    var _session_id = window.localStorage.getItem("_session_id");
    var logged_in_userId = window.localStorage.getItem("logged_in_userId");

    if (_session_id === null || _session_id === '') {
        // no logged user, we should be going to #login
        if (next.templateUrl === "templates/login.html") {
            // already going to #login, no redirect needed
        } else {
            // not going to #login, we should redirect now
            $location.path("/login");
        }
    } else {
        $location.path("/main");
    }

});
4

2 に答える 2

0

どうやら数週間待ってから再試行すると、Phonegap Build が追いつくことができました。再試行すると、プラグインが認識され、音声録音ダイアログが表示されました...

于 2014-04-20T23:42:47.067 に答える
0

Phonegap Build でプラグインをテストするのにかなりの時間を費やしましたが、プラグインは Phonegap 2.9 では機能しますが、Phonegap Build のバージョン 3.1 および 3.3 では機能しないことがわかりました。

回避策はなく、iOS と Android 用にローカルでビルドすることにしました。

Phonegap プラットフォームには、ローカルでビルドする場合でもプラグインに関するいくつかの問題があり、このスクリプトは iOS 側でそれを修正しました。

#!/bin/bash
echo "Killing xcode..."
killall Xcode

rm -rf platforms/ios
rm plugins/ios.json
cordova platform add ios
cordova build ios
node .cordova/hooks/after_build/copy_icons_screens.js 
## Above isn't being caught by the hook during iOS for some reason. Hook is caught by Android build
open platforms/ios/*.xcodeproj

Android 側では、必ず CordovaLib プロジェクトをクリーンアップしてから、AppName プロジェクトをクリーンアップしてください。順序が重要です。

ここのアイコンのコピーとプラグインのインストールフックも重要です。

于 2014-04-01T04:27:41.503 に答える