通过精确定位发送的通知消息无法到达移动

时间:2018-05-18 03:15:53

标签: android-push-notification

根据我尝试过的link工作,这是我尝试过的代码

    public static void SendNotification2(String appid, String pinpointEndpointId){


    try {
        GetEndpointRequest getEndpointRequest = new GetEndpointRequest()
                   .withApplicationId(appid)
                   .withEndpointId(pinpointEndpointId);

        AmazonPinpoint pinpoint = AmazonPinpointClientBuilder.standard().withRegion(Regions.US_EAST_1).build();

        GetEndpointResult endpointResult = pinpoint.getEndpoint(getEndpointRequest);

        EndpointResponse endpointResponse = endpointResult.getEndpointResponse();

        Map<String, String> data = new HashMap<String, String>();

        data.put("message", "test");


        DirectMessageConfiguration directMessageConfiguration =
                new DirectMessageConfiguration().withGCMMessage(new GCMMessage().withData(data).withSilentPush(true));
        AddressConfiguration addressConfiguration = new AddressConfiguration().withChannelType(ChannelType.GCM);

        MessageRequest messageRequest = new MessageRequest().withMessageConfiguration(directMessageConfiguration)
            .addAddressesEntry(endpointResponse.getAddress(), addressConfiguration);

        SendMessagesRequest sendMessagesRequest = new SendMessagesRequest()
            .withApplicationId(appid)
            .withMessageRequest(messageRequest);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}

代码执行成功,没有任何错误/异常,但我没有看到通知。 但是,当我发布来自&#34; Direct Messaging&#34;使用端点ID精确定位的部分我能够在移动设备中看到通知。

还使用Amazon CLI传递通知消息:

aws --region="us-east-1" pinpoint send-messages --application-id 1fd19ca6fa944a79bdd91beddb4b4f7e --message-request "{\"Context\":{},\"MessageConfiguration\":{\"DefaultMessage\":{\"Body\":\"Test from default message\",\"Substitutions\":{}},\"DefaultPushNotificationMessage\":{},\"APNSMessage\":{},\"GCMMessage\":{\"Data\":{\"message\":\"test\"},\"SilentPush\":true},\"BaiduMessage\":{},\"ADMMessage\":{},\"SMSMessage\":{}},\"Addresses\":{\"cltaa5owuOU:APA91bFOBUB5YRi_Ac6teNmuu19aoFDAByOeoVbqLmY1Yp6cZEp_aueunDU1ZPB6H50GKBfuxu300z-El_sEjxo72crYKnklI-wboxXDk180JICrif0c7R-fR4xFOm5WsQOGUJZPFLG6\":{\"ChannelType\":\"GCM\"}},\"Endpoints\":{}}

任何帮助将不胜感激。 感谢

0 个答案:

没有答案