I am working on ionic Framework (ionic own generator). Now some of the functionality (e.g., local notification, or taking picture from mobile camera) i want to add in my app. I have this folder structure in my Project root
hooks
node_modules
platform (android included)
scss
www
some files etc.,**
now how can i add functionality into my project. I know that cordova\phoneGap provide these kind of functionality but how to add that and how can i use those plugin in my controller?
You can use ngCordova. http://ngcordova.com/
local notification
module.controller('MyCtrl', function($scope, $cordovaLocalNotification) {
$scope.addNotification = function () {
$cordovaLocalNotification.add({
id: 'some_notification_id'
// parameter documentation:
// https://github.com/katzer/cordova-plugin-local-notifications#further-informations-1
}).then(function () {
console.log('callback for adding background notification');
});
};
$scope.cancelNotification = function () {
$cordovaLocalNotification.cancel('some_notification_id').then(function () {
console.log('callback for cancellation background notification');
});
};
$scope.cancelAllNotification = function () {
$cordovaLocalNotification.cancelAll().then(function () {
console.log('callback for canceling all background notifications');
});
};
$scope.checkIfIsScheduled = function () {
$cordovaLocalNotification.isScheduled('some_notification_id').then(function (isScheduled) {
console.log(isScheduled);
});
};
$scope.getNotificationIds = function () {
$cordovaLocalNotification.getScheduledIds().then(function (scheduledIds) {
console.log(scheduledIds);
});
};
$scope.checkIfIsTriggered = function () {
$cordovaLocalNotification.isTriggered('some_notification_id').then(function (isTriggered) {
console.log(isTriggered);
});
};
$scope.getTriggeredIds = function () {
$cordovaLocalNotification.getTriggeredIds().then(function (triggeredIds) {
console.log(triggeredIds);
});
};
$scope.notificationDefaults = $cordovaLocalNotification.getDefaults();
$scope.setDefaultOptions = function () {
$cordovaLocalNotification.setDefaults({ autoCancel: true });
};
// event callbacks events `onadd`, `ontrigger`, `onclick` and `oncancel`
// can be assigned like this:
$cordovaLocalNotification.onadd = function (id, state, json) {};
});
camera
module.controller('PictureCtrl', function($scope, $cordovaCamera) {
var options = {
quality : 75,
destinationType : Camera.DestinationType.DATA_URL,
sourceType : Camera.PictureSourceType.CAMERA,
allowEdit : true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
// Success! Image data is here
}, function(err) {
// An error occurred. Show a message to the user
});
});