apptentive-react-native icon indicating copy to clipboard operation
apptentive-react-native copied to clipboard

Android Message Callback

Open bpfeiffer187 opened this issue 6 years ago • 2 comments

I have found the android message callback for react native to not be working. I use the call back to then display how many unread messages the user has from us. it works on iOS fine.

let side is iOS right side is android image

I have created a custom component to handle this.

here is the code: const handlePressMessage = () => { Apptentive.presentMessageCenter(); };

export const AppUnread = () => { const [unReadCount, setUnReadCount] = useState(0); const callback = (count: number) => { setUnReadCount(count); }; Apptentive.onUnreadMessageCountChanged = callback; return ( <View> <SectionHeader>Messages</SectionHeader> <InfoCard title={You have ${unReadCount} unread messages from Amica.} buttonTitle="Message Center" onPress={handlePressMessage} /> </View> ) };

export default AppUnread;

bpfeiffer187 avatar Oct 29 '19 12:10 bpfeiffer187

Hi @bpfeiffer187,

Apptentive SDK uses message polling technique so most likely you would see 5 min delay between sending messages from the dashboard and receiving them in the app. If you can't get any callbacks on the unread messages and but can see messages in the Message Center - try this snippet to verify that the callback still get invoked:

Apptentive.register(configuration)
  .then(() => {
    Apptentive.onUnreadMessageCountChanged = (count) => {
      console.log("Unread message count: " + count);
    };
  })
  .catch((error) => {
    showAlert('Error', `Can't register Apptentive:\n${error.message}`);
  });

Don't use your current callback when you check this (since it would overwrite the first callback)

weeeBox avatar Oct 29 '19 22:10 weeeBox

Hi @bpfeiffer187 , Were you able to resolve the issue with the code snippet provided above?

twinklesharma1311 avatar Nov 12 '19 19:11 twinklesharma1311