I was looking for different ways to support offline messaging in my application but each of these examples include parseBareAdress and Android studio gives error stating that it cannot resolve parseBareAdress. It can resolve everything else. Here is my code
import org.jivesoftware.smack.util.StringUtils;
public static void handleOfflineMessages(XMPPConnection connection, Context ctx)throws Exception {
OfflineMessageManager offlineMessageManager = new OfflineMessageManager(connection);
if (!offlineMessageManager.supportsFlexibleRetrieval()) {
Log.d(TAG,"Offline messages not supported");
return;
}
if (offlineMessageManager.getMessageCount() == 0) {
Log.d(TAG,"No offline messages found on server");
} else {
List<Message> msgs = offlineMessageManager.getMessages();
for (Message msg : msgs) {
String fullJid = msg.getFrom();
String bareJid = StringUtils.parseBareAddress(fullJid);
String messageBody = msg.getBody();
if (messageBody != null) {
Log.d(TAG,"Retrieved offline message from " +messageBody);
}
}
offlineMessageManager.deleteMessages();
}
}
Here are my dependencies
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0-alpha6'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0-alpha6'
Replace
StringUtils.parseBareAddress(fullJid)
with this custom method: