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;

           }

  • 相关阅读:
    mysql "ON DUPLICATE KEY UPDATE" 语法
    HTTP协议中PUT和POST使用区别
    layui 表单渲染失败
    golang 一行代码 把array/slice转成逗号分隔的字符串
    关于layui、table数据表格请求异常回调函数
    关于layui表单中按钮自动提交的解决方法
    使用 socket.io 报错 Error during WebSocket handshake: Unexpected response code: 400
    解决MySQL报错:[Err] 1055
    jetbrains 修改 http proxy 更换代理
    layui layuiadmin layui.data 数据操作
  • 原文地址:https://www.cnblogs.com/sundaysjava/p/11957858.html
Copyright © 2011-2022 走看看