File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed
android/src/main/java/com/mackentoch/beaconsandroid Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ public void bindManager() {
78
78
mBeaconManager .bind (this );
79
79
}
80
80
81
+ @ ReactMethod
82
+ public void unbindManager () {
83
+ mBeaconManager .unbind (this );
84
+ }
85
+
81
86
@ ReactMethod
82
87
public void addParser (String parser ) {
83
88
mBeaconManager .getBeaconParsers ().add (new BeaconParser ().setBeaconLayout (parser ));
Original file line number Diff line number Diff line change @@ -92,15 +92,34 @@ async function bindManager(): Promise<any> {
92
92
return new Promise ( ( resolve , reject ) => {
93
93
this . bindListener = DeviceEventEmitter . addListener ( 'bindStatus' , ( { status} ) => {
94
94
if ( status ) {
95
- resolve ( status )
95
+ resolve ( status ) ;
96
96
}
97
97
else {
98
- reject ( status )
98
+ reject ( status ) ;
99
99
}
100
- DeviceEventEmitter . removeListener ( 'bindStatus' , this . bindListener )
100
+ DeviceEventEmitter . removeListener ( 'bindStatus' , this . bindListener ) ;
101
101
} ) ;
102
102
BeaconsManager . bindManager ( ) ;
103
- } )
103
+ } ) ;
104
+ }
105
+
106
+ /**
107
+ * unbind the service
108
+ *
109
+ */
110
+ async function unbindManager ( ) : Promise < any > {
111
+ return new Promise ( ( resolve , reject ) => {
112
+ this . bindListener = DeviceEventEmitter . addListener ( 'bindStatus' , ( { status} ) => {
113
+ if ( status ) {
114
+ resolve ( status ) ;
115
+ }
116
+ else {
117
+ reject ( status ) ;
118
+ }
119
+ DeviceEventEmitter . removeListener ( 'bindStatus' , this . bindListener ) ;
120
+ } ) ;
121
+ BeaconsManager . unbindManager ( ) ;
122
+ } ) ;
104
123
}
105
124
106
125
/**
@@ -275,6 +294,7 @@ module.exports = {
275
294
detectEddystoneURL,
276
295
detectEddystoneEID,
277
296
bindManager,
297
+ unbindManager,
278
298
detectCustomBeaconLayout,
279
299
setBackgroundScanPeriod,
280
300
setBackgroundBetweenScanPeriod,
You can’t perform that action at this time.
0 commit comments