Skip to content

Commit

Permalink
Only send custom msg for Android. For ios, we need send notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
good-life committed Jan 16, 2014
1 parent 5a9f5b5 commit 3892e65
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions server-java/src/org/pushtalk/server/api/TalkServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
import org.pushtalk.server.web.common.FreemarkerBaseServlet;

import cn.jpush.api.JPushClient;
import cn.jpush.api.common.DeviceEnum;
import cn.jpush.api.push.CustomMessageParams;
import cn.jpush.api.push.IosExtras;
import cn.jpush.api.push.MessageResult;
import cn.jpush.api.push.NotificationParams;
import cn.jpush.api.push.ReceiverTypeEnum;

public class TalkServlet extends FreemarkerBaseServlet {
Expand Down Expand Up @@ -69,41 +66,24 @@ public void process(HttpServletRequest request,
Map<String, Object> extras = new HashMap<String, Object>();
extras.put("channel", channelName);
extras.put("sendNo", sendId);
if (udid.startsWith("iPhone")) {
IosExtras ios = new IosExtras(1, "default");
extras.put("ios", ios);
NotificationParams params = new NotificationParams();
params.addPlatform(DeviceEnum.IOS);
params.setReceiverType(ReceiverTypeEnum.TAG);
params.setReceiverValue(ServiceUtils.postfixAliasAndTag(channelName));
jpushClient.sendNotification(content, params, extras);
} else {
CustomMessageParams params = new CustomMessageParams();
params.setReceiverType(ReceiverTypeEnum.TAG);
params.setReceiverValue(ServiceUtils.postfixAliasAndTag(channelName));
jpushClient.sendCustomMessage(myName, content, params, extras);
}

CustomMessageParams params = new CustomMessageParams();
params.setReceiverType(ReceiverTypeEnum.TAG);
params.setReceiverValue(ServiceUtils.postfixAliasAndTag(channelName));
msgResult = jpushClient.sendCustomMessage(myName, content, params, extras);

chatting = ServiceUtils.getChattingChannel(channelName);
}
} else {
sendId ++;
Map<String, Object> extras = new HashMap<String, Object>();
extras.put("sendNo", sendId);
if (udid.startsWith("iPhone")) {
IosExtras ios = new IosExtras(1, "default");
extras.put("ios", ios);
NotificationParams params = new NotificationParams();
params.addPlatform(DeviceEnum.IOS);
params.setReceiverType(ReceiverTypeEnum.ALIAS);
params.setReceiverValue(ServiceUtils.postfixAliasAndTag(friend));
jpushClient.sendNotification(content, params, extras);
} else {
CustomMessageParams params = new CustomMessageParams();
params.setReceiverType(ReceiverTypeEnum.TAG);
params.setReceiverValue(ServiceUtils.postfixAliasAndTag(friend));
jpushClient.sendCustomMessage(myName, content, params, extras);
}

CustomMessageParams params = new CustomMessageParams();
params.setReceiverType(ReceiverTypeEnum.ALIAS);
params.setReceiverValue(ServiceUtils.postfixAliasAndTag(friend));
msgResult = jpushClient.sendCustomMessage(myName, content, params, extras);

chatting = ServiceUtils.getChattingChannel(myName, friend);
}

Expand Down

0 comments on commit 3892e65

Please sign in to comment.