/** * 构建推送对象:平台是 Andorid 与 iOS,推送目标是 ("tag1" 与 "tag2" 的并集) 且("alias1" 与 "alias2" 的并集),推送内容是 - 内容为 * MSG_CONTENT 的消息, 并且附加字段 from = JPush。 * * @return */ private static PushPayload buildPushObject_ios_audienceMore_messageWithExtras() { return PushPayload.newBuilder() .setPlatform(Platform.android_ios()) .setAudience( Audience.newBuilder() .addAudienceTarget(AudienceTarget.tag("tag1", "tag2")) .addAudienceTarget(AudienceTarget.alias("alias1", "alias2")) .build()) .setMessage( Message.newBuilder().setMsgContent("MSG_CONTENT").addExtra("from", "JPush").build()) .setOptions(Options.newBuilder().setApnsProduction(PRODUCT_MODE).build()) .build(); }
/** * 构建推送对象:平台是 iOS,推送目标是 "tag1", "tag_all" 的交集, 推送内容同时包括通知与消息 - 通知信息是 ALERT,角标数字为 5,通知声音为 "happy", * 并且附加字段 from = "JPush";消息内容是 MSG_CONTENT。通知是 APNs 推送通道的, 消息是 JPush 应用内消息通道的。APNs * 的推送环境是“生产”(如果不显式设置的话,Library 会默认指定为开发) * * @return */ private static PushPayload buildPushObject_ios_tagAnd_alertWithExtrasAndMessage( String target, String targetAll, String messageTitle, String message, String otherTitle, String otherMessage) { return PushPayload.newBuilder() .setPlatform(Platform.ios()) .setAudience(Audience.tag_and(target, targetAll)) .setNotification( Notification.newBuilder() .addPlatformNotification( IosNotification.newBuilder() .setAlert(messageTitle) .setBadge(5) .setSound("happy.caf") .addExtra(otherTitle, otherMessage) .build()) .build()) .setMessage(Message.content(message)) .setOptions(Options.newBuilder().setApnsProduction(PRODUCT_MODE).build()) .build(); }