极光推送的设置


1、Tag推送——————按照分类推送

public static PushPayload buildPushObject_all_alias_alert(String gender, String title) {

        return PushPayload
                .newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.tag(gender, "secret"))
                .setNotification(
                        Notification
                                .newBuilder()
                                .setAlert(title)
                                .addPlatformNotification(
                                        IosNotification.newBuilder().setSound("default").setBadge(1).addExtras(null)
                                                .build())
                                .addPlatformNotification(AndroidNotification.newBuilder().build()).build()).build();

    }



2、Alias推送(定点推送 不带参数)
    public static PushPayload buildPushObject_memberId_alias_alert(String memberId, String title) {
        return PushPayload
                .newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.alias(memberId))
                .setNotification(
                        Notification
                                .newBuilder()
                                .setAlert(title)
                                .addPlatformNotification(
                                        IosNotification.newBuilder().setSound("default").setBadge(1).addExtras(null)
                                                .build())
                                .addPlatformNotification(AndroidNotification.newBuilder().build()).build()).build();
    }


3、Alias推送(定点推送 带参数)

public static PushPayload buildPushObject_memberId_alias_alert(String memberId, String title, String id, int type) {
        // 补充要传递的参数
        Map<String, String> ex = new HashMap<String, String>();
        ex.put("id", id);
        ex.put("type", type + "");
        return PushPayload
                .newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.alias(memberId))
                .setNotification(
                        Notification
                                .newBuilder()
                                .setAlert(title)
                                .addPlatformNotification(
                                        IosNotification.newBuilder().setSound("default").setBadge(1).addExtras(ex)
                                                .build())
                                .addPlatformNotification(AndroidNotification.newBuilder().addExtras(ex).build())
                                .build()).build();

    }

4、静默推送

public static PushPayload buildPushObject_memberId_alias_silenceAlert(String memberId, String title,int id,int classfyID,int type) {
        return PushPayload
                .newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.alias(memberId))
                .setNotification(
                        Notification
                                .newBuilder()
                                .setAlert("")
                                .addPlatformNotification(
                                        IosNotification.newBuilder().setContentAvailable(true).addExtra("classfyID",classfyID)
                                                .build())
                                .build())
                .setMessage(
                        Message
                             .newBuilder()
                             .setMsgContent("")
                             .addExtra("classfyID",classfyID).build()
                        )
                .setOptions(Options.newBuilder().setApnsProduction(true).build())        
                .build();
    }


5、广播

    public static PushPayload buildPushObject_all_all_alert(String title) {
        // return PushPayload.alertAll(title);
        return PushPayload
                .newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.all())
                .setNotification(
                        Notification
                                .newBuilder()
                                .setAlert(title)
                                .addPlatformNotification(
                                        IosNotification.newBuilder().setSound("default").setBadge(1).addExtras(null)
                                                .build())
                                .addPlatformNotification(AndroidNotification.newBuilder().build()).build()).build();
    }



/**
补充 苹果开发者模式设置,否则前端iphone无法接收到推送数据

  public static PushPayload enterpriseNotPassAlert(String id, int type, String reason) {
        // 补充要传递的参数
        Map<String, String> ex = new HashMap<String, String>();
        id = "enterprise_" + id;
        ex.put("type", type + "");
        ex.put("parttimeId", "");

        reason = "您的企业资料审核未通过,原因如下:" + reason;
        ex.put("reason", "您的企业资料审核未通过,原因如下:" + reason);
        return PushPayload
                .newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.alias(id))
                .setOptions(Options.newBuilder().setApnsProduction(true).build())
                .setNotification(
                        Notification
                                .newBuilder()
                                .setAlert(reason)
                                .addPlatformNotification(
                                        IosNotification.newBuilder().setSound("default").setBadge(1).addExtras(ex)
                                                .build())
                                .addPlatformNotification(AndroidNotification.newBuilder().addExtras(ex).build())
                                .build()).build();

    }



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值