-
Notifications
You must be signed in to change notification settings - Fork 0
/
ionicIbeacon.js
102 lines (76 loc) · 2.23 KB
/
ionicIbeacon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
ionic start IonicBeacon blank
cd IonicBeacon
ionic platform add ios
ionic platform add android
ionic start IonicBeacon blank
cd IonicBeacon
ionic platform add ios
ionic platform add android
<
script src = "js/ng-cordova-beacon.min.js" > < /script>
$cordovaBeacon.createBeaconRegion("estimote", "b9407f30-f5f8-466e-aff9-25556b57fe6d")
angular.module('starter', ['ionic', 'ngCordovaBeacon'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller("ExampleController", function($scope, $rootScope, $ionicPlatform, $cordovaBeacon) {
$scope.beacons = {};
$ionicPlatform.ready(function() {
$cordovaBeacon.requestWhenInUseAuthorization();
$rootScope.$on("$cordovaBeacon:didRangeBeaconsInRegion", function(event, pluginResult) {
var uniqueBeaconKey;
for (var i = 0; i < pluginResult.beacons.length; i++) {
uniqueBeaconKey = pluginResult.beacons[i].uuid + ":" + pluginResult.beacons[i].major + ":" + pluginResult.beacons[i].minor;
$scope.beacons[uniqueBeaconKey] = pluginResult.beacons[i];
}
$scope.$apply();
});
$cordovaBeacon.startRangingBeaconsInRegion($cordovaBeacon.createBeaconRegion("kontakt", "f7826da6-4fa2-4e98-8024-bc5b71e0893e"));
});
});
<
ion - content ng - controller = "ExampleController" >
<
div class = "list" >
<
div class = "item"
ng - repeat = "(key, value) in beacons" >
<
div class = "row" >
<
div class = "col truncate" > {
{ value.uuid } } <
/div> <
/div> <
div class = "row" >
<
div class = "col" >
major: {
{ value.major } } <
/div> <
div class = "col" >
minor: {
{ value.minor } } <
/div> <
/div> <
div class = "row" >
<
div class = "col" > {
{ value.proximity } } <
/div> <
/div> <
/div> <
/div> <
/ion-content>
.truncate {
overflow: hidden;
text - overflow: ellipsis;
white - space: nowrap;
}