cn.jpush.api.push.model.audience.Audience Java Examples

The following examples show how to use cn.jpush.api.push.model.audience.Audience. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPushUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("static-access")
private PushPayload buildPushObject_Alias(String type, String title, String msg, Map<String, String> extras,String[] alias) { 
	if(null == extras){ 
		extras = new HashMap<String,String>(); 
	} 
	return PushPayload.newBuilder() 
			.setPlatform(Platform.all()) 
			.setAudience(Audience.newBuilder() 
					.addAudienceTarget(AudienceTarget.alias(alias)) 
					.build()) 
					.setMessage(Message.newBuilder() 
							.setMsgContent(type) 
							.addExtras(extras) 
							.build()).setOptions(Options.newBuilder() 
			                         .setApnsProduction(true) 
			                         .build()) 
							.setNotification(Notification.android(msg, title, extras).ios(title, extras)) 
							.build(); 
}
 
Example #2
Source File: JpushInterface.java    From java_server with MIT License 6 votes vote down vote up
public static PushPayload buildPushObject_ios_tagAnd_alertWithExtrasAndMessage(String message, String msg_content) {
    return PushPayload.newBuilder()
            .setPlatform(Platform.ios())
            .setAudience(Audience.tag_and("tag1", "tag_all"))
            .setNotification(Notification.newBuilder()
                    .addPlatformNotification(IosNotification.newBuilder()
                            .setAlert(message)
                            .setBadge(5)
                            .setSound("happy")
                            .addExtra("from", "JPush")
                            .build())
                    .build())
            .setMessage(Message.content(msg_content))
            .setOptions(Options.newBuilder()
                    .setApnsProduction(true)
                    .build())
            .build();
}
 
Example #3
Source File: JPushUtils.java    From classchecks with Apache License 2.0 6 votes vote down vote up
private static PushPayload buildPushObject_android_regId_alert(String pushAlert, String pushTitle, List<String> regIds) {
	
	Map<String, String> extras = new HashMap<String, String>();
    extras.put("extra_1", "val1");
    extras.put("extra_2", "val2");
	
	return PushPayload.newBuilder()
			.setPlatform(Platform.android())
			.setAudience(Audience.registrationId(regIds))
			.setNotification(Notification
					.newBuilder()
					.setAlert(pushAlert)
					.addPlatformNotification(AndroidNotification.newBuilder()
							.setTitle(pushTitle)
							.addExtras(extras)
							.build())
					.build())
			.build();
}
 
Example #4
Source File: JPushUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
private PushPayload buildPushObject_Alias_IOS(String type, String title,Map<String, String> extras,String[] alias) { 
	if(null == extras){ 
		extras = new HashMap<String,String>(); 
	} 
	return PushPayload.newBuilder() 
			.setPlatform(Platform.all()) 
			.setAudience(Audience.newBuilder() 
					.addAudienceTarget(AudienceTarget.alias(alias)) 
					.build()) 
					.setMessage(Message.newBuilder() 
							.setMsgContent(type) 
							.addExtras(extras) 
							.build()).setOptions(Options.newBuilder() 
			                         .setApnsProduction(true) 
			                         .build()) 
							.setNotification(Notification.ios(title, extras)) 
							.build(); 
}
 
Example #5
Source File: JPushUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
private PushPayload buildPushObjec_Tag_IOS(String type, String title,Map<String, String> extras,String[] tags) { 
	if(null == extras){ 
		extras = new HashMap<String,String>(); 
	} 
	return PushPayload.newBuilder() 
			.setPlatform(Platform.all()) 
			.setAudience(Audience.newBuilder() 
					.addAudienceTarget(AudienceTarget.tag_and(tags)) 
					.build()) 
					.setMessage(Message.newBuilder() 
							.setMsgContent(type) 
							.addExtras(extras) 
							.build()).setOptions(Options.newBuilder() 
			                         .setApnsProduction(true) 
			                         .build()) 
							.setNotification(Notification.ios(title, extras)) 
							.build(); 
}
 
Example #6
Source File: JPushUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
private PushPayload buildPushObject_Alias_Android(String type, String title, String msg, Map<String, String> extras,String[] alias) { 
	if(null == extras){ 
		extras = new HashMap<String,String>(); 
	} 
	return PushPayload.newBuilder() 
			.setPlatform(Platform.all()) 
			.setAudience(Audience.newBuilder() 
					.addAudienceTarget(AudienceTarget.alias(alias)) 
					.build()) 
					.setMessage(Message.newBuilder() 
							.setMsgContent(type) 
							.addExtras(extras) 
							.build()).setOptions(Options.newBuilder() 
			                         .setApnsProduction(true) 
			                         .build()) 
							.setNotification(Notification.android(msg, title, extras)) 
							.build(); 
}
 
Example #7
Source File: JPushUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
private PushPayload buildPushObjec_Tag_Android(String type, String title, String msg, Map<String, String> extras,String[] tags) { 
	if(null == extras){ 
		extras = new HashMap<String,String>(); 
	} 
	return PushPayload.newBuilder() 
			.setPlatform(Platform.all()) 
			.setAudience(Audience.newBuilder() 
					.addAudienceTarget(AudienceTarget.tag_and(tags)) 
					.build()) 
					.setMessage(Message.newBuilder() 
							.setMsgContent(type) 
							.addExtras(extras) 
							.build()).setOptions(Options.newBuilder() 
			                         .setApnsProduction(true) 
			                         .build()) 
							.setNotification(Notification.android(msg, title, extras)) 
							.build(); 
}
 
Example #8
Source File: JPushUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unused", "static-access" })
private PushPayload buildPushObjectByTag(String type, String title, String msg, Map<String, String> extras,String[] tags) { 
	if(null == extras){ 
		extras = new HashMap<String,String>(); 
	} 
	return PushPayload.newBuilder() 
			.setPlatform(Platform.all()) 
			.setAudience(Audience.newBuilder() 
					.addAudienceTarget(AudienceTarget.tag_and(tags)) 
					.build()) 
					.setMessage(Message.newBuilder() 
							.setMsgContent(type) 
							.addExtras(extras) 
							.build()).setOptions(Options.newBuilder() 
			                         .setApnsProduction(true) 
			                         .build()) 
							.setNotification(Notification.android(msg, title, extras).ios(title, extras)) 
							.build(); 
}
 
Example #9
Source File: JPushUtils.java    From classchecks with Apache License 2.0 5 votes vote down vote up
/**
    * 
   * @Title: buildPushObject_all_tags_teacher_alert 
   * @Description: TODO(学生端) 
   * @return
   * PushPayload 
    */
private static PushPayload buildPushObject_android_tags_alert(String tag, String pushAlert, String pushTitle) {
       return PushPayload.newBuilder()
               .setPlatform(Platform.android())//设置接受的平台
               .setAudience(Audience.tag(tag))//Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
               .setNotification(Notification.newBuilder()
               		.setAlert(pushAlert)
               		.addPlatformNotification(AndroidNotification.newBuilder()
               				.setTitle(pushTitle).build())
               		.build())
               .build();
   }
 
Example #10
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload buildPushObject_all_all_alert(String message) {
    return PushPayload.newBuilder()
            .setPlatform(Platform.android_ios())
            .setAudience(Audience.all())
            .setNotification(Notification.alert(message))
            .setOptions(Options.newBuilder().setApnsProduction(false).build())
            .setMessage(Message.newBuilder()
                    .setMsgContent(message)
                    .addExtra("from", "foryou")
                    .build())
            .build();
}
 
Example #11
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload buildPushObject_android_and_ios_alias_alert(String alertString, String phone) {

        return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.alias(phone))
                .setNotification(Notification.alert(alertString))
                .setOptions(Options.newBuilder().setApnsProduction(false
                ).build())
                .setMessage(Message.newBuilder()
                        .setMsgContent(alertString)
                        .addExtra("from", "foryou")
                        .build())
                .build();
    }
 
Example #12
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload buildPushObject_android_and_ios_tag_alert(
        String message, String tag) {
    return PushPayload.newBuilder()
            .setPlatform(Platform.android_ios())
            .setAudience(Audience.tag(tag))
            .setNotification(Notification.alert(message))
            .setOptions(Options.newBuilder().setApnsProduction(false).build())
            .setMessage(Message.newBuilder()
                    .setMsgContent(message)
                    .addExtra("from", "foryou")
                    .build())
            .build();
}
 
Example #13
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload buildPushObject_android__alertWithTitle(String message, String title) {
    return PushPayload.newBuilder()
            .setPlatform(Platform.android())
            .setAudience(Audience.tag("tag1"))
            .setNotification(Notification.android(message, title, null))
            .build();
}
 
Example #14
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload buildPushObject_android_and_ios() {
    return PushPayload.newBuilder()
            .setPlatform(Platform.android_ios())
            .setAudience(Audience.tag("tag1"))
            .setNotification(Notification.newBuilder()
                    .setAlert("alert content")
                    .addPlatformNotification(AndroidNotification.newBuilder()
                            .setTitle("Android Title").build())
                    .addPlatformNotification(IosNotification.newBuilder()
                            .incrBadge(1)
                            .addExtra("extra_key", "extra_value").build())
                    .build())
            .build();
}
 
Example #15
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload buildPushObject_ios_audienceMore_messageWithExtras(String msg_content) {
    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())
            .build();
}
 
Example #16
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload bulidPushObject_ios_alert(String message) {
    return PushPayload.newBuilder()
            .setPlatform(Platform.ios())
            .setAudience(Audience.all())
            .setNotification(Notification.alert(message))
            .setMessage(Message.newBuilder()
                    .setMsgContent(message)
                    .addExtra("from", "mickey")
                    .build())
            .build();
}
 
Example #17
Source File: JpushInterface.java    From java_server with MIT License 5 votes vote down vote up
public static PushPayload bulidPushObject_android_alert(String message) {
    return PushPayload.newBuilder()
            .setPlatform(Platform.android())
            .setAudience(Audience.all())
            .setNotification(Notification.alert(message))
            .setMessage(Message.newBuilder()
                    .setMsgContent(message)
                    .addExtra("from", "mickey")
                    .build())
            .build();
}
 
Example #18
Source File: ApiBootMessagePushJiGuangServiceImpl.java    From api-boot with Apache License 2.0 2 votes vote down vote up
/**
 * add alias to push payload
 *
 * @param alias   alias list
 * @param builder push payload builder
 */
private void addAliasMeta(List<String> alias, PushPayload.Builder builder) {
    if (!ObjectUtils.isEmpty(alias)) {
        builder.setAudience(Audience.alias(alias));
    }
}
 
Example #19
Source File: ApiBootMessagePushJiGuangServiceImpl.java    From api-boot with Apache License 2.0 2 votes vote down vote up
/**
 * add tag
 *
 * @param messagePushBody push message body
 * @param builder         push payload builder
 */
private void addTagMeta(MessagePushBody messagePushBody, PushPayload.Builder builder) {
    if (!ObjectUtils.isEmpty(messagePushBody.getTags())) {
        builder.setAudience(Audience.tag(messagePushBody.getTags()));
    }
}