mirror of
https://github.com/status-im/instabug-reactnative.git
synced 2025-03-02 14:10:40 +00:00
Use Callbacks in getUnReadMessage
API
This commit is contained in:
parent
3148a9b529
commit
1365d040ca
@ -3,8 +3,7 @@
|
||||
* https://github.com/facebook/react-native
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React, {Component} from 'react';
|
||||
import React, {Component} from "react";
|
||||
import {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
@ -17,10 +16,9 @@ import {
|
||||
Image,
|
||||
ListView,
|
||||
TouchableHighlight,
|
||||
RecyclerViewBackedScrollView,
|
||||
} from 'react-native';
|
||||
|
||||
import Instabug from'instabug-reactnative';
|
||||
RecyclerViewBackedScrollView
|
||||
} from "react-native";
|
||||
import Instabug from "instabug-reactnative";
|
||||
let DialogAndroid = require('react-native-dialogs');
|
||||
|
||||
export default class InstabugSample extends Component {
|
||||
@ -77,8 +75,11 @@ export default class InstabugSample extends Component {
|
||||
} else if (rowID == 3) {
|
||||
Instabug.showIntroMessage();
|
||||
} else if (rowID == 4) {
|
||||
Alert.alert("UnReadMessages", "Messages: " +
|
||||
Instabug.getUnreadMessagesCount());
|
||||
|
||||
Instabug.getUnreadMessagesCount((count) => {
|
||||
Alert.alert("UnReadMessages", "Messages: " + count);
|
||||
});
|
||||
|
||||
} else if (rowID == 5) {
|
||||
this._showLocaleActionSheet();
|
||||
} else if (rowID == 6) {
|
||||
|
@ -8,6 +8,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
|
||||
import com.instabug.library.Instabug;
|
||||
import com.instabug.library.internal.module.InstabugLocale;
|
||||
@ -450,7 +451,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
* @return number of messages that are unread for this user
|
||||
*/
|
||||
@ReactMethod
|
||||
public int getUnreadMessagesCount() {
|
||||
public void getUnreadMessagesCount(Callback messageCountCallback) {
|
||||
int unreadMessages = 0;
|
||||
try {
|
||||
unreadMessages = mInstabug.getUnreadMessagesCount();
|
||||
@ -458,7 +459,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return unreadMessages;
|
||||
messageCountCallback.invoke(unreadMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
8
index.js
8
index.js
@ -198,14 +198,10 @@ module.exports = {
|
||||
* Use this method to get the number of unread messages the user
|
||||
* has, then possibly notify them about it with your own UI.
|
||||
* @param {messageCountCallback} messageCountCallback callback with argument
|
||||
* Notifications count, or -1 incase the SDK has not been initialized.
|
||||
* Notifications count, or -1 in case the SDK has not been initialized.
|
||||
*/
|
||||
getUnreadMessagesCount: function (messageCountCallback) {
|
||||
if (Platform.OS === 'ios') {
|
||||
Instabug.getUnreadMessagesCount(messageCountCallback);
|
||||
} else if (Platform.OS === 'android') {
|
||||
Instabug.getUnreadMessagesCount();
|
||||
}
|
||||
Instabug.getUnreadMessagesCount(messageCountCallback);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user