C# JPushClient 调用SendPush的时候报1002,


(severus) #1

ios的推送是没有问题的,但安卓的就报错1002,同用的APP,通用的推送代码.
以下为推送代码,

MessageResult result=null;
                List<string> insert_list = new List<string>();
                JPushClient pushclient = new JPushClient(APP_KEY, MASTER_SECRET);
                StringBuilder sbids = new StringBuilder();
                if (ds == null) { return; }
                for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                {
PushPayload pushpayload = new PushPayload();
pushpayload.platform = Platform.android_ios();
 pushpayload.audience = Audience.s_tag("tag_"+ds.Tables[0].Rows[j]["DEVICE_ID"].ToString());
if (push_hours > 0)
                    {
                        pushpayload.options.time_to_live = push_hours * 60;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(this.textBox2.Text)) return;
                        pushpayload.options.time_to_live = Convert.ToInt32(this.textBox2.Text);
                    }
 pushpayload.notification = new Notification().setIos(new IosNotification().setAlert("[测试]"+ds.Tables[0].Rows[j]["LOM_TITLE"].ToString()).incrBadge(1).setContentAvailable(true)
                        );
 pushpayload.options.sendno = 1440;
 try
                    {
                        result = pushclient.SendPush(pushpayload);   //发送
                    }
                    catch (APIRequestException ex)
                    {
                    }
}

以上这段为报错的地方.苹果的没有报错,安卓的就报1002.


#2

1002 缺少了必须的参数
请去检查参数

另:


(severus) #5

谢谢你的回复,但ios的没有问题的,可以收到推送.
我在测试的时候,就用这两个设备,安卓报1002,ios成功推送

PushPayload pushpayload = new PushPayload();
pushpayload.platform = Platform.android_ios();

pushpayload.audience = Audience.s_tag(“tag_352571071419331_android”);
pushpayload.audience = Audience.s_tag(“tag_38510A28C7B84348B9385A54732B2442_ios”);


#6

有1002报错那肯定是有问题的呀,譬如说你只给iOS传了值,没给Android的notification传值等,你看具体的错误信息有没有体现,或者返回的完整内容里面少了啥