Skip to content

Commit

Permalink
Merge pull request #10 from tcruzibt/master
Browse files Browse the repository at this point in the history
Fix error on parsing notification
  • Loading branch information
realtime-framework committed Oct 12, 2015
2 parents 72b5633 + bce90de commit d1abc9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
public class Config {

final public static String CLUSTERURL = "http://ortc-developers.realtime.co/server/2.1/";
//final public static String CLUSTERURL = null;
final public static String URL = null;
final public static String METADATA = "androidApp";
final public static String TOKEN = "token";
final public static String APPKEY = "YOUR_APPLICATION_KEY";
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/handlers/OrtcHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void prepareClient(Context context, InterfaceRefresher rootView){
if(Config.CLUSTERURL != null){
client.setClusterUrl(Config.CLUSTERURL);
} else {
client.setUrl(Config.CLUSTERURL);
client.setUrl(Config.URL);
}

client.setApplicationContext(selfHandler.context);
Expand Down
16 changes: 11 additions & 5 deletions app/src/main/java/receiver/GcmReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import co.realtime.messagingandroidchat.MessageActivity;
import co.realtime.messagingandroidchat.NotificationActivity;
import co.realtime.messagingandroidchat.R;
import ibt.ortc.api.Ortc;
import ibt.ortc.extensibility.GcmOrtcBroadcastReceiver;
import ibt.ortc.plugins.IbtRealtimeSJ.OrtcMessage;

Expand Down Expand Up @@ -58,10 +56,18 @@ public void createNotification(Context context, Bundle extras)
try {

// parsed message format: <user>:<chat message>
String user = null;
String chatMessage = null;
if(parsedMessage.contains(":"))
{
user = parsedMessage.substring(0, parsedMessage.indexOf(":"));
chatMessage = parsedMessage.substring(parsedMessage.indexOf(":") + 1);
}
else {
user = "Unknown user";
chatMessage = parsedMessage;
}

String parts [] = parsedMessage.split(":");
String user = parts[0].split("_")[parts[0].split("_").length - 1];
String chatMessage = parts[1];

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, NotificationActivity.class);
Expand Down

0 comments on commit d1abc9d

Please sign in to comment.