zoukankan      html  css  js  c++  java
  • Jpush给 iOS 平台推送 title 值失败

    https://community.jiguang.cn/t/ios-title/27090

    IosAlert iosAlert = IosAlert.newBuilder()

        .setTitleAndBody("test alert", "subtitle", "test ios alert json")

        .setActionLocKey("PLAY")

        .build();

    PushPayload payload = PushPayload  

    .newBuilder()  

    .setPlatform(Platform.all())  

    .setAudience(Audience.alias(pushMsg.getAlias()))//Audience.alias(alias.replace(".", "_"))  

    .setNotification(  

            Notification  

                    .newBuilder()  

                    .addPlatformNotification(  

                            IosNotification.newBuilder()  

                                    .setAlert(iosAlert)//notification

                                    .setSound("happy.caf")

                                    .addExtras(pushMsg.getExtras())//extras

                                    .build())

    public boolean sendNotificationWithAlias(com.wybs.bbs.dal.model.JPushMsg pushMsg){

                try {

                    ClientConfig clientConfig = ClientConfig.getInstance();

                   JPushClient jpushClient = new JPushClient(masterSecret, appKey);

                    String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);

                    ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);

                    jpushClient.getPushClient().setHttpClient(httpClient);

                    

                    IosAlert iosAlert = IosAlert.newBuilder()

                        .setTitleAndBody(pushMsg.getTitle(), "", pushMsg.getAlert())

                        .build();

                    

                    PushPayload payload = PushPayload  

                    .newBuilder()  

                    .setPlatform(Platform.android_ios())  

                    .setAudience(Audience.alias(pushMsg.getAlias()))//Audience.alias(alias.replace(".", "_"))  

                    .setNotification(  

                            Notification  

                                    .newBuilder()  

                                    .addPlatformNotification(  

                                            IosNotification.newBuilder()  

                                                    .setAlert(iosAlert)//notification

                                                    .setSound("default")

                                                    .addExtras(pushMsg.getExtras())//extras

                                                    .build())

                                    .addPlatformNotification(  

                                            AndroidNotification.newBuilder()  

                                                    .setAlert(pushMsg.getAlert())//notification

                                                    .setTitle(pushMsg.getTitle())

                                                    .addExtras(pushMsg.getExtras())//extras

                                                    .build())

                                    .build())

                                            .setOptions(Options.newBuilder()

                                            .setApnsProduction(true)

                                            .build()).build();  

                    PushResult result = jpushClient.sendPush(payload);

                    logger.debug("sendNotificationWithAlias() - push all - msgId={}, title={}, notification={}, alias={}, payload={}",result.msg_id, pushMsg.getTitle(), pushMsg.getAlert(), pushMsg.getAlias(), payload);

                    return result.isResultOK();

                } catch (APIConnectionException e) {

                    logger.debug("APIConnectionException:"+e.getMessage());

                    e.printStackTrace();

                } catch (APIRequestException e) {

                    logger.debug("APIConnectionException:"+e.getMsgId());

                    e.printStackTrace();

                }

                return false;

           }

  • 相关阅读:
    Java 下载网络资源
    Java11 ThreadLocal的remove()方法源码分析
    软件测试的术语SRS,HLD,LLD,BD,FD,DD意义
    2020年12月2日
    20201129
    2020年11月28日
    程序员的三门课
    中间件到底是个什么鬼东西?
    接口测试框架的形成过程
    一个字符到底等于多少字节
  • 原文地址:https://www.cnblogs.com/sundaysjava/p/11957858.html
Copyright © 2011-2022 走看看