Closed gabema closed 10 years ago
Hi Gabe. Sorry about that. Are replies showing up in your app's Apptentive Message Center? If so, then most likely you aren't triggering an app launch. Because Android doesn't provide an easy way to detect when the app was launched, we must infer one. To trigger an app launch, you would need to exit the app, wait 10 seconds, and open it again. We currently fetch messages on app launch, so this should trigger the listener. I am working on a background fetching feature for this sprint, so this will be easier to verify in the future. Please let me know if this doesn't solve your problem.
Sky
Figured out the problem. I was assuming the unreadMessage listener would be calling back on the UI thread and had some debug code to ensure this was happening and would throw an IllegalStateException if not called on the UI thread. Turns out the listener was not getting called on the UI thread but the exception was getting handled by apptentive. I now handle marshalling to the UI thread in response to the unreadMessages listener. Still requires restarting the app to see new unread messages but better late than never.
Thanks Gabe.
Since we last talked, I've released version 1.4.0, which polls for new messages while your app is in the foreground, but our Message Center is in the background. So your customer won't have to restart the app to see new messages anymore. Note that some of the APIs have changed, and there is a migration guide for those in the docs folder. If you have any trouble upgrading, please let me know.
Sky
Im still facing this issue (using V1.6). I put this code in my base activity: Apptentive.setUnreadMessagesListener(new UnreadMessagesListener() {
@Override
public void onUnreadMessageCountChanged(int unreadMessages) {
Toast.makeText(context, "Unread message: " + unreadMessages, Toast.LENGTH_SHORT).show();
}
});
Note: When i open message center -> i receive notification
And i got the error log:
11-26 14:59:03.034: V/Apptentive(24113): Sending Error Metric: error, data: {"thread":"Apptentive-MessagePollingWorker","exception":{"message":"Can't create handler inside thread that has not called Looper.prepare()","stackTrace":"java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()\n\tat android.os.Handler.
Hello Duc,
I'm sorry you're seeing this problem. The problem is caused because the listener is not being called from the UI thread. The solution is to make sure that you show your Toast from the UI thread instead of just calling it in the listener method.
Here is an example:
Apptentive.setUnreadMessagesListener(new UnreadMessagesListener() {
public void onUnreadMessageCountChanged(final int unreadMessages) {
runOnUiThread(new Runnable() {
public void run() {
if (lastUnreadMessageCount < unreadMessages) {
Toast.makeText(MainActivity.this, "You have " + unreadMessages + " unread messages.", Toast.LENGTH_SHORT).show();
}
}
});
lastUnreadMessageCount = unreadMessages;
}
});
Please let me know if you have any trouble implementing this. I will add clarification to the documentation.
I've integrated apptentive using the steps provided in the Readme. Specifically I am hooking into my activity lifecycle using delegation. I'm never receiving events of new unread messages via the setUnreadMessagesListener on the client. Also, I noticed that viewing the messages via the website that all of the users messages are marked as unread even though I've viewed them in the message center.