1
정확도가없는 devgirls post을 기반으로하는 Angular 팩토리에서 PushPlugin을 래핑하려고합니다.Phonegap/Cordova 함수가 각도 팩토리
TypeError: '[object Object]' is not a function (evaluating 'e.registerPush(function(a){console.log("fun"),console.log(a)})')
내가 잘못 뭐하는 거지 :
angular.module('phonegap', [])
.factory('phonegapReady', function ($rootScope, $q) {
var loadingDeferred = $q.defer();
document.addEventListener('deviceready', function() {
$rootScope.$apply(loadingDeferred.resolve);
});
return function phonegapReady() {
return loadingDeferred.promise;
};
})
.factory('push', function ($rootScope, phonegapReady) {
return {
registerPush: phonegapReady().then(function (onSuccess, onError) {
// stripped handlers
if (device.platform === 'android' || device.platform === 'Android') {
pushNotification.register(
function() {
var that = this,
args = arguments;
if (onSuccess) {
$rootScope.$apply(function() {
onSuccess.apply(that, args);
});
}
},
function() {
var that = this,
args = {
'senderID': '123',
'ecb': 'onNotificationGCM'
};
if (onError) {
$rootScope.$apply(function() {
onError.apply(that, args);
});
}
}
);
} else {
pushNotification.register(
function() {
var that = this,
args = arguments;
if (onSuccess) {
$rootScope.$apply(function() {
onSuccess.apply(that, args);
});
}
},
function() {
var that = this,
args = {
'badge': 'true',
'sound': 'true',
'alert': 'true',
'ecb': 'onNotificationAPN'
};
if (onError) {
$rootScope.$apply(function() {
onError.apply(that, args);
});
}
}
);
}
})
};
});
오류를 얻기?