Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit da92644

Browse files
committed
feat(demo): add contacts + localNotification changes
1 parent 6b6739f commit da92644

File tree

6 files changed

+84
-44
lines changed

6 files changed

+84
-44
lines changed

demo/www/app/app.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
angular.module('demo', [
22
'ionic',
33
'ngCordova',
4-
'ngCordova.plugins.fileOpener2',
54

65
// modules
7-
// 'demo.adMob.ctrl', // not working???
6+
// 'demo.adMob.ctrl', -- not functioning right now
87
'demo.appAvailability.ctrl',
98
'demo.appRate.ctrl',
109
'demo.barcodeScanner.ctrl',
@@ -39,7 +38,7 @@ angular.module('demo', [
3938
'demo.vibration.ctrl'
4039
])
4140

42-
.run(function ($rootScope, $ionicPlatform, $cordovaNetwork, $cordovaBatteryStatus) {
41+
.run(function ($rootScope, $ionicPlatform, $cordovaNetwork, $cordovaBatteryStatus, $cordovaLocalNotification) {
4342

4443
$ionicPlatform.ready(function () {
4544
if (window.cordova && window.cordova.plugins.Keyboard) {
@@ -49,20 +48,22 @@ angular.module('demo', [
4948
StatusBar.styleDefault();
5049
}
5150

52-
$cordovaNetwork.watchOffline();
53-
$cordovaNetwork.watchOnline();
54-
51+
$cordovaLocalNotification.registerPermission().then(function () {
52+
alert("registered");
53+
}, function () {
54+
alert("denied registration");
55+
});
5556

56-
$rootScope.$on("networkOffline", function () {
57+
$rootScope.$on("$cordovaNetwork:offline", function () {
5758
alert("Device is now Offline!");
5859
});
5960

6061

61-
$rootScope.$on("networkOnline", function () {
62+
$rootScope.$on("$cordovaNetwork:online", function () {
6263
alert("Device is Online!");
6364
});
6465

65-
$cordovaBatteryStatus.$on("batterystatus", function (status) {
66+
$cordovaBatteryStatus.$on("$cordovaBatteryStatus:status", function (status) {
6667
alert("status :" + status);
6768
})
6869
})
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
angular.module('demo.contacts.ctrl', [])
22

3-
.controller('ContactsCtrl', function ($scope, $log, $cordovaPreferences) {
3+
.controller('ContactsCtrl', function ($scope, $log, $cordovaContacts) {
4+
5+
$scope.pickContact = function () {
6+
document.addEventListener("deviceready", function () {
7+
$cordovaContacts.pickContact().then(function (result) {
8+
console.log(JSON.stringify(result));
9+
$scope.selectedContact = result;
10+
})
11+
}, false);
12+
};
13+
14+
$scope.saveContact = function (contact) {
15+
document.addEventListener("deviceready", function () {
16+
$cordovaContacts.save(contact).then(function (result) {
17+
console.log(JSON.stringify(result));
18+
})
19+
}, false);
20+
};
21+
22+
23+
$scope.removeContact = function (contact) {
24+
document.addEventListener("deviceready", function () {
25+
$cordovaContacts.remove(contact).then(function (result) {
26+
console.log(JSON.stringify(result));
27+
})
28+
}, false);
29+
};
430

531
});

demo/www/app/contacts/contacts.html

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,47 @@
77

88

99
<ion-view title="Contacts">
10-
<ion-content>
11-
<div class="list">
12-
<label class="item item-input">
13-
<input type="text" ng-model="contact" placeholder="Contact info">
14-
</label>
15-
16-
</div>
17-
18-
19-
<div class="padding">
20-
<button class="button button-block button-positive" ng-click="save(contact)">
21-
Create new Contact
22-
</button>
23-
24-
</div>
25-
26-
<div class="list">
27-
<label class="item item-input">
28-
<input type="text"
29-
ng-model="data.value"
30-
placeholder="Remove - contact">
31-
</label>
32-
</div>
33-
34-
<div class="padding">
35-
<button class="button button-block button-positive" ng-click="remove(contact)">
36-
Paste!
37-
</button>
38-
</div>
39-
</ion-content>
10+
<ion-content>
11+
12+
<div class="padding-horizontal">
13+
<button class="button button-block button-balanced" ng-click="pickContact()">
14+
Pick a Contact from Phone
15+
</button>
16+
</div>
17+
18+
<div class="card" ng-if="selectedContact != undefined">
19+
<div class="item">
20+
<h3>NAME: {{selectedContact.name.givenName}} {{selectedContact.name.familyName}}</h3>
21+
</div>
22+
</div>
23+
24+
<div class="list">
25+
<label class="item item-input item-floating-label">
26+
<span class="input-label">Create new Contact</span>
27+
<input type="text" placeholder="Create new Contact" ng-model="newContact">
28+
</label>
29+
</div>
30+
31+
<div class="padding-horizontal">
32+
<button class="button button-block button-positive" ng-click="saveContact(newContact)">
33+
Create new Contact
34+
</button>
35+
</div>
36+
<br>
37+
38+
<div class="list">
39+
<label class="item item-input item-floating-label">
40+
<span class="input-label">Remove a Contact</span>
41+
<input type="text" placeholder="Remove a Contact" ng-model="oldContact">
42+
</label>
43+
</div>
44+
45+
<div class="padding-horizontal">
46+
<button class="button button-block button-assertive" ng-click="removeContact(contact)">
47+
Remove Contact
48+
</button>
49+
</div>
50+
51+
52+
</ion-content>
4053
</ion-view>

demo/www/app/localNotification/localNotification.ctrl.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ angular.module('demo.localNotification.ctrl', [])
22

33
.controller('LocalNotificationCtrl', function ($scope, $rootScope, $cordovaLocalNotification) {
44

5-
/// NOTE LOCAL NOTIFICATIONS ARE BROKEN
6-
75
$scope.addNotification = function () {
86
var now = new Date();
97
var _60_seconds_from_now = new Date(now + 60 * 1000);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ion-view title="Local Notification">
22
<ion-content padding="true">
33

4-
<button class="button button-block" ng-click="addNotification()" disabled>Add Notification</button>
4+
<button class="button button-block" ng-click="addNotification()">Add Notification</button>
55
</ion-content>
66
</ion-view>

demo/www/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
99
<link href="css/style.css" rel="stylesheet">
1010
<script src="lib/ionic/js/ionic.bundle.js"></script>
11+
<div id="fb-root"></div>
1112

1213
<!-- Facebook Plugin for web-development -->
1314
<script>
@@ -31,7 +32,7 @@
3132

3233
<!-- cordova script (this will be a 404 during development) -->
3334
<script src="cordova.js"></script>
34-
35+
3536
<!-- your app's js -->
3637
<script src="app/app.js"></script>
3738
<script src="app/adMob/adMob.ctrl.js"></script>
@@ -49,6 +50,7 @@
4950
<script src="app/dialogs/dialogs.ctrl.js"></script>
5051
<script src="app/facebook/facebook.ctrl.js"></script>
5152
<script src="app/file/file.ctrl.js"></script>
53+
<script src="app/fileOpener2/fileOpener2.ctrl.js"></script>
5254
<script src="app/flashlight/flashlight.ctrl.js"></script>
5355
<script src="app/geolocation/geolocation.ctrl.js"></script>
5456
<script src="app/globalization/globalization.ctrl.js"></script>

0 commit comments

Comments
 (0)