package com.fos.demo.push;

import com.fos.core.fetcher.HCFetcher;
import com.fos.core.push.MessageClient;
import com.fos.core.push.MessagePayload;

public class DemoTedaPushMain {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        boolean isProduction = true;// 是否为调试模式，只用于控制iOS的推送
        String  pushToken    = "TEDA123456";
        
        MessagePayload payload = MessagePayload.newPayload()
                .setAppkey("79d056105a30e1329efc140df9785817")
                .setToPeople(MessagePayload.To.BY_TOKEN)
                .setPushToken(pushToken)
                .setProduction(isProduction)
                .addMessageTitle("你有1条新消息")
                .addMessageContent("")
                .addDevices(new String[]{"8668771238902252cdf4cf"})
                .addMessageExtra("type", "MS60001")// 设置自定义KEY-VALUE
                .addMessageExtra("user_channel", "1001")// 设置自定义KEY-VALUE
                .addMessageExtra("type", "MS30001")// 设置自定义KEY-VALUE
                .addMessageExtra("p_user_id", "qfaJiy2QuExYqjIKxc5TGhyui2RJXEtK");// 设置自定义KEY-VALUE
        System.out.println("POST: "+payload);
        String server = "http://123.56.146.81:1880/v1/";
        String ret    = MessageClient.post(server, payload);// 调用推送接口
        // {"flag":1,"msg":"ok","mkey":56} 返回接口flag=1则说明发送成功，其余为发送不成功
        System.out.println(ret);
        
        // 测试 com.okayapps.message.service.sample
//        MessagePayload payload = MessagePayload.newPayload()
//                .setAppkey("98475b7244ca1e1816a05f5c54f6d191")
//                .setToPeople(MessagePayload.To.BY_TOKEN)
//                .setPushToken("rq_2015")
//                .setProduction(false)
//                .addMessageTitle("你有1条新消息")
//                .addMessageContent("")
//                .addDevices(new String[]{"8668771238902252cdf4cf"})
//                .addMessageExtra("type", "MS60001")// 设置自定义KEY-VALUE
//                .addMessageExtra("user_channel", "1001")// 设置自定义KEY-VALUE
//                .addMessageExtra("type", "MS30001")// 设置自定义KEY-VALUE
//                .addMessageExtra("p_user_id", "qfaJiy2QuExYqjIKxc5TGhyui2RJXEtK");// 设置自定义KEY-VALUE
//        System.out.println("POST: "+payload);
//        String server = "http://123.56.146.81:1880/v1/";
//        String ret    = MessageClient.post(server, payload);// 调用推送接口
//        System.out.println(ret);
        
        
        HCFetcher.getInstance().shutdown();
    }

}
