android – 在Cordova中的CallLog访问插件不工作

android – 在Cordova中的CallLog访问插件不工作,第1张

概述嗨,我正在使用cordova开发混合应用程序.我试图访问在 Android手机中使用CallLog插件错过的最后一个电话.这是我试过的, 1.I installed the plugin with this command cordova plugin add https://github.com/dalyc/Cordova-CallLog-Plugin.git.2.I am using ang 嗨,我正在使用cordova开发混合应用程序.我试图访问在 Android手机中使用CallLog插件错过的最后一个电话.这是我试过的,
1.I installed the plugin with this command cordova plugin add https://github.com/dalyc/Cordova-CallLog-Plugin.git.2.I am using angularJs.I have this app.Js.var app=angular.module('lmp',['ngCordova']);     app.controller('lmpctrl',['$scope','CallLogService',function($scope,CallLogService){        $scope.data = {};                $scope.callTypedisplay = function(type) {                    switch(type) {                        case 1:                            return 'Incoming';                        case 2:                            return 'Outgoing';                        case 3:                            return 'Missed';                        default:                            return 'UnkNown';                    }};                CallLogService.List(1).then(                    function(callLog) {                        console.log(callLog);                        $scope.data.lastCall = callLog[0];                    },function(error) {                        console.error(error);                    });            }]);     app.factory('CallLogService',['$q',function($q) {            return {                List : function(days) {                    var q = $q.defer();                    // days is how many days back to go                    window.plugins.calllog.List(days,function (response) {                        q.resolve(response.rows);                    },function (error) {                        q.reject(error)                    });                    return q.promise;                },contact : function(phoneNumber) {                    var q = $q.defer();                    window.plugins.calllog.contact(phoneNumber,function (response) {                        q.resolve(response);                    },show : function(phoneNumber) {                    var q = $q.defer();                    window.plugins.calllog.show(phoneNumber,delete : function(phoneNumber) {                    var q = $q.defer();                    window.plugins.calllog.delete(ID,function (error) {                        q.reject(error)                    });                    return q.promise;                }            }        }]);3.This is my index.HTML.<body ng-app="lmp">        <div ng-controller="lmpctrl">            <div >                <div >Last Call</div>            </div>            <div >                <div >name</div>                <div >{{data.lastCall.cachedname}}</div>            </div>            <div >                <div >Number</div>                <div >{{data.lastCall.number}}</div>            </div>            <div >                <div >Type</div>                <div >{{callTypedisplay(data.lastCall.type)}}</div>            </div>            <div >                <div >Date</div>                <div >{{data.lastCall.date | date}}</div>            </div>            <div >                <div >Duration</div>                <div >{{data.lastCall.duration}} seconds</div>            </div>            <div >                <div >AckNowledged</div>                <div >{{(data.lastCall.new == 1 ? 'yes' : 'no')}}</div>            </div>        </div>        <script src="Js/angular.min.Js"></script>          <script src="Js/app.Js"></script>        <script src="Js/ng-cordova.Js"></script>        <script type="text/JavaScript" src="cordova.Js"></script>        <script type="text/JavaScript" src="Js/index.Js"></script>4.I added this following code in my config.xml<feature name="CallLog">                <param name="androID-package" value="com.ubookr.plugins.CallLogPlugin"/>            </feature>

我错过了一些东西,或者我错了.有人可以提前帮我.

解决方法 似乎window.plugins是未定义的.我所做的是避免在DeviceReady事件而不是使用ng-app指令手动引导AngularJs,如 Cordova + Angularjs + Device Ready

为此,请从< body>中删除ng-app指令元素,并将此JavaScript放在您的app.Js脚本之上:

document.addEventListener('deviceready',function() {    var body = document.querySelector('body');    angular.bootstrap(body,['lmp']);},false);

这将等待设备准备好引导角度,确保所有设备服务在使用之前都可用.

总结

以上是内存溢出为你收集整理的android – 在Cordova中的CallLog访问插件不工作全部内容,希望文章能够帮你解决android – 在Cordova中的CallLog访问插件不工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1133443.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存