2016-04-01 12 views
0

私はアプリ内の位置ベースの通知用にプロットプロジェクトプラグインを使用しています:http://www.plotprojects.com/。 アプリはionic cordovaフレームワーク上に構築されています。
$ ionicPlatform.ready()関数の中でplot.init()を呼び出しています。
しかし、plot.isEnabled()関数は、アプリケーションを起動した後にPlotが無効になることがあるため、出力を提供します。それはランダムに起こります。後でplot.isEnabled()メソッドをコールして、plotの正しいステータスを取得する必要がありますか?プロットプロジェクト - プロットプラグインがアプリ内で正常に初期化されていません

$ionicPlatform.ready(function() { 
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard 
    // for form inputs) 
    if (window.cordova && window.cordova.plugins.Keyboard) { 
    cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); 
    cordova.plugins.Keyboard.disableScroll(true); 

    } 
    if (window.StatusBar) { 
     //org.apache.cordova.statusbar required 
     StatusBar.styleDefault(); 
    } 
    //window.localStorage.setItem("IsLaunched","YES"); 
    var plot = cordova.require("cordova/plugin/plot"); 
     plot.init(); 
     console.log('after plot init'); 
    plot.isEnabled(function(enabled) { 
    var plotEnabledState = enabled ? "enabled" : "disabled"; 
    console.log("Plot is " + plotEnabledState); 
}, function (err) { 
    console.log("Failed to determine whether Plot is enabled: " + err); 
}); 

答えて

1

Plotが初期化されるまでに時間がかかります。プロットはバックグラウンドで初期化されます。 plot.init()を呼び出した直後にplot.isEnabled()を呼び出すと、falseが返されます。しばらく待ってからplot.isEnabled()を呼び出すと、trueが返されます。

関連する問題