I don’t have an iPhone or a mac book…
So, the iPhone version would be difficult to me… But I will be very pleased to merge an implementation if somebody want to do it !
For the ngCordova wrapper, it could be great but this project is not mature enought I think… (no tests, api not really eprouved…).
But I can share the service I use to wrap it in my app :
// for Accounts plugin : hhttps://github.com/loicknuchel/cordova-device-accounts
.factory('AccountsSrv', function($q, $window, $ionicPlatform){
'use strict';
var service = {
getAccounts: getAccounts,
getByType: getByType,
getEmails: getEmails,
getEmail: getEmail
};
function getAccounts(){
var defer = $q.defer();
pluginReady(function(){
$window.plugins.DeviceAccounts.get(function(accounts){
defer.resolve(accounts);
}, function(error){
defer.reject(error);
});
});
return defer.promise;
}
function getByType(type){
var defer = $q.defer();
pluginReady(function(){
$window.plugins.DeviceAccounts.getByType(type, function(accounts){
defer.resolve(accounts);
}, function(error){
defer.reject(error);
});
});
return defer.promise;
}
function getEmails(){
var defer = $q.defer();
pluginReady(function(){
$window.plugins.DeviceAccounts.getEmails(function(emails){
defer.resolve(emails);
}, function(error){
defer.reject(error);
});
});
return defer.promise;
}
function getEmail(){
var defer = $q.defer();
pluginReady(function(){
$window.plugins.DeviceAccounts.getEmail(function(email){
defer.resolve(email);
}, function(error){
defer.reject(error);
});
});
return defer.promise;
}
function pluginReady(fn){
$ionicPlatform.ready(function(){
if($window.plugins && $window.plugins.DeviceAccounts){
fn();
} else {
console.log('pluginNotFound:DeviceAccounts');
}
});
}
return service;
})
It can be used like this :
AccountsSrv.getEmail().then(function(email){
// some work with first user email registered on device
});
Hi @loicknuchel
I want you help me into plugin get device cordova accounts in ionic with method app.js. What about you share a controller or factory as share you below.