File tree Expand file tree Collapse file tree 3 files changed +14
-16
lines changed
android/src/main/java/com/instabug/reactlibrary Expand file tree Collapse file tree 3 files changed +14
-16
lines changed Original file line number Diff line number Diff line change 3
3
* https://github.com/facebook/react-native
4
4
* @flow
5
5
*/
6
-
7
- import React , { Component } from 'react' ;
6
+ import React , { Component } from "react" ;
8
7
import {
9
8
AppRegistry ,
10
9
StyleSheet ,
@@ -17,10 +16,9 @@ import {
17
16
Image ,
18
17
ListView ,
19
18
TouchableHighlight ,
20
- RecyclerViewBackedScrollView ,
21
- } from 'react-native' ;
22
-
23
- import Instabug from 'instabug-reactnative' ;
19
+ RecyclerViewBackedScrollView
20
+ } from "react-native" ;
21
+ import Instabug from "instabug-reactnative" ;
24
22
let DialogAndroid = require ( 'react-native-dialogs' ) ;
25
23
26
24
export default class InstabugSample extends Component {
@@ -77,8 +75,11 @@ export default class InstabugSample extends Component {
77
75
} else if ( rowID == 3 ) {
78
76
Instabug . showIntroMessage ( ) ;
79
77
} else if ( rowID == 4 ) {
80
- Alert . alert ( "UnReadMessages" , "Messages: " +
81
- Instabug . getUnreadMessagesCount ( ) ) ;
78
+
79
+ Instabug . getUnreadMessagesCount ( ( count ) => {
80
+ Alert . alert ( "UnReadMessages" , "Messages: " + count ) ;
81
+ } ) ;
82
+
82
83
} else if ( rowID == 5 ) {
83
84
this . _showLocaleActionSheet ( ) ;
84
85
} else if ( rowID == 6 ) {
Original file line number Diff line number Diff line change 8
8
import com .facebook .react .bridge .ReactMethod ;
9
9
import com .facebook .react .bridge .ReadableArray ;
10
10
import com .facebook .react .bridge .ReadableMap ;
11
+ import com .facebook .react .bridge .Callback ;
11
12
12
13
import com .instabug .library .Instabug ;
13
14
import com .instabug .library .internal .module .InstabugLocale ;
@@ -450,15 +451,15 @@ public String getAppToken() {
450
451
* @return number of messages that are unread for this user
451
452
*/
452
453
@ ReactMethod
453
- public int getUnreadMessagesCount () {
454
+ public void getUnreadMessagesCount (Callback messageCountCallback ) {
454
455
int unreadMessages = 0 ;
455
456
try {
456
457
unreadMessages = mInstabug .getUnreadMessagesCount ();
457
458
} catch (Exception e ) {
458
459
e .printStackTrace ();
459
460
}
460
461
461
- return unreadMessages ;
462
+ messageCountCallback . invoke ( unreadMessages ) ;
462
463
}
463
464
464
465
/**
Original file line number Diff line number Diff line change @@ -198,14 +198,10 @@ module.exports = {
198
198
* Use this method to get the number of unread messages the user
199
199
* has, then possibly notify them about it with your own UI.
200
200
* @param {messageCountCallback } messageCountCallback callback with argument
201
- * Notifications count, or -1 incase the SDK has not been initialized.
201
+ * Notifications count, or -1 in case the SDK has not been initialized.
202
202
*/
203
203
getUnreadMessagesCount : function ( messageCountCallback ) {
204
- if ( Platform . OS === 'ios' ) {
205
- Instabug . getUnreadMessagesCount ( messageCountCallback ) ;
206
- } else if ( Platform . OS === 'android' ) {
207
- Instabug . getUnreadMessagesCount ( ) ;
208
- }
204
+ Instabug . getUnreadMessagesCount ( messageCountCallback ) ;
209
205
} ,
210
206
211
207
/**
You can’t perform that action at this time.
0 commit comments