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 33 * https://github.com/facebook/react-native
44 * @flow
55 */
6-
7- import React , { Component } from 'react' ;
6+ import React , { Component } from "react" ;
87import {
98 AppRegistry ,
109 StyleSheet ,
@@ -17,10 +16,9 @@ import {
1716 Image ,
1817 ListView ,
1918 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" ;
2422let DialogAndroid = require ( 'react-native-dialogs' ) ;
2523
2624export default class InstabugSample extends Component {
@@ -77,8 +75,11 @@ export default class InstabugSample extends Component {
7775 } else if ( rowID == 3 ) {
7876 Instabug . showIntroMessage ( ) ;
7977 } 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+
8283 } else if ( rowID == 5 ) {
8384 this . _showLocaleActionSheet ( ) ;
8485 } else if ( rowID == 6 ) {
Original file line number Diff line number Diff line change 88import com .facebook .react .bridge .ReactMethod ;
99import com .facebook .react .bridge .ReadableArray ;
1010import com .facebook .react .bridge .ReadableMap ;
11+ import com .facebook .react .bridge .Callback ;
1112
1213import com .instabug .library .Instabug ;
1314import com .instabug .library .internal .module .InstabugLocale ;
@@ -450,15 +451,15 @@ public String getAppToken() {
450451 * @return number of messages that are unread for this user
451452 */
452453 @ ReactMethod
453- public int getUnreadMessagesCount () {
454+ public void getUnreadMessagesCount (Callback messageCountCallback ) {
454455 int unreadMessages = 0 ;
455456 try {
456457 unreadMessages = mInstabug .getUnreadMessagesCount ();
457458 } catch (Exception e ) {
458459 e .printStackTrace ();
459460 }
460461
461- return unreadMessages ;
462+ messageCountCallback . invoke ( unreadMessages ) ;
462463 }
463464
464465 /**
Original file line number Diff line number Diff line change @@ -198,14 +198,10 @@ module.exports = {
198198 * Use this method to get the number of unread messages the user
199199 * has, then possibly notify them about it with your own UI.
200200 * @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.
202202 */
203203 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 ) ;
209205 } ,
210206
211207 /**
You can’t perform that action at this time.
0 commit comments