jpush / jpush-api-csharp-client Goto Github PK
View Code? Open in Web Editor NEWJPush's officially supported C# client library for accessing JPush APIs. 极光推送官方支持的 C# 版本服务器端 SDK。
Home Page: https://docs.jiguang.cn
License: MIT License
JPush's officially supported C# client library for accessing JPush APIs. 极光推送官方支持的 C# 版本服务器端 SDK。
Home Page: https://docs.jiguang.cn
License: MIT License
由于业务需要,通知,extras需要添加复杂json数据,现添加如下方法
希望,作者,添加如下功能到新版sdk当中
cn.jpush.api.push.notification 命名空间下
AndroidNotification.cs
添加以下方法 public AndroidNotification AddExtra(string key, object value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
if (value != null)
{
extras.Add(key, value);
}
return this;
}
IosNotification.cs
添加以下方法 public IosNotification AddExtra(string key, object value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
if (value != null)
{
extras.Add(key, value);
}
return this;
}
WinphoneNotification.cs
添加以下方法 public WinphoneNotification AddExtra(string key, object value)
{
if (extras == null)
{
extras = new Dictionary<string, object>();
}
if (value != null)
{
extras.Add(key, value);
}
return this;
It would be better to have a nuget package for the C# SDK.
cn.jpush.api.push.notification.AndroidNotification 下的参数 url_activity是否为支持华为推送参数uri_activity
项目地址:https://www.nuget.org/packages/cn.jpush.api/
参考文档:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#notification
缺少字段:thread-id
另外:Notification.cs中的Indent应该是Intent
版本工具 : vs 2012
报错提示:
错误 58 未能找到类型或命名空间名称“cn”(是否缺少 using 指令或程序集引用?)
尝试方法:
将c# 版本提升为4.5 正常编译通过
但是现在项目用的是4.0 版本,查看dll信息,说是可以运行在4.0平台的,现在为何不行??
希望官方能完善代码注释 , 并生成xml文档,打到nuget包里.
方便开发的时候引用查看,
时时打开官网api文档也是不太方便的.
谢谢
The Annotations is necessary. Also in the DLL.
搜索下Task死锁
文档:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#options
字段:apns_production
抓包如下:
{
"name": "task1",
"enabled": true,
"push": {
"platform": "all",
"audience": "all",
"notification": {
"alert": "Hello JPush AtTime"
},
"message": {
"msg_content": "message content AtTime",
"title": "message title AtTime",
"content_type": "text",
"extras": {}
},
"options": {
"sendno": 0,
"time_to_live": 0,
"override_msg_id": 0,
"apns_production": false,
"big_push_duration": 0
}
},
"trigger": {
"single": {
"time": "2017-10-20 14:22:26"
}
}
}
我的代码
PushPayload pushPayload = new PushPayload();
pushPayload.Platform = "all";
pushPayload.Notification = new Notification()
{
Alert = "Hello JPush AtTime"
};
pushPayload.Message = new Message()
{
Title = "message title AtTime",
Content = "message content AtTime",
ContentType = "text",
Extras = new Dictionary<string, string>()
};
//pushPayload.Options = new Options() { };
var response = client.Schedule.CreateSingleScheduleTask("task1", pushPayload, DateTime.Now.AddSeconds(5).ToString("yyyy-MM-dd HH:mm:ss"));
What if the client does not have a console window attached to?
Please consider using a logging facade so that the client application can choose whatever logging library.
如果发的时间是singler,用下面方式初始化,在 使用ScheduleClient.putSchedule 会抛异常。请修复下
public TriggerPayload(String time) { Preconditions.checkArgument(!String.IsNullOrEmpty(time), "The time must not be empty."); Preconditions.checkArgument(StringUtil.IsDateTime(time), "the time is not valid"); Single single = new Single(); single.setTime(time); this.single = single; periodical = null; }
+e{"远程服务器返回错误: (401) 未经授权。"} cn.jpush.api.common.APIRequestException
ConsoleApplication,vs2013,.net Framework4.5
调用示例的代码,将notify content替换为中文出现了乱码
notification.IosNotification = new IosNotification()
.AddExtra("Type", "Follow")
.AddExtra("Param", paraJson)
.setSound("default") //无效,通过日志调试,发现sound始终为空
.setAlert(entity.Summary);
发送请求时发生了这样的错误。在本地windows环境调试时却一切正常。
cn.jpush.api.common.resp.APIConnectionException: Error: TrustFailure (The authentication or decryption has failed.)
at cn.jpush.api.common.BaseHttpClient.sendRequest (System.String method, System.String url, System.String auth, System.String reqParams) [0x003df] in :0
at cn.jpush.api.common.BaseHttpClient.sendPost (System.String url, System.String auth, System.String reqParams) [0x00001] in :0
at cn.jpush.api.push.PushClient.sendPush (System.String payloadString) [0x0002f] in :0
at cn.jpush.api.push.PushClient.sendPush (cn.jpush.api.push.mode.PushPayload payload) [0x0001e] in :0
at cn.jpush.api.JPushClient.SendPush (cn.jpush.api.push.mode.PushPayload payload) [0x00010] in :0
请问c#这边如何给 iOS 平台的通知设置标题/副标题,用 web 端可以,为何在 IosNotification类中没有找到相应的属性去设置,只能单纯的设置 alert显示消息内容.
As the title suggests.
运行cn.jpush.api.example项目,根据RegistrationID发送notification成功,发送customermessage失败。 错误信息“Registration ID is not belong to the appkey”
但是在web portal发送是成功的,可以确认的是Registration ID肯定是属于appkey的
上传不了图片.... 就是demo 里面的这句发送推送的请求
var response =client.SendPushAsync(pushPayload).Result;
执行到这里就一直没有反应了,页面也卡住了
,但推送已发送成功,android已收到通知
JPushClient类中 public static System.Net.Http.HttpClient HttpClient 静态对象
https://github.com/jpush/jpush-api-csharp-client/blob/master/Jiguang.JPush/JPushClient.cs
#原来环境是vs2013,看到不支持c#6,就下载了vs2015,可是vs2015运行后一直报错,这是报错(未能加载文件或程序集“System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11“)。不过项目中我引用了System.Net.Http。这个demo我也运行不起来啊
参见:下面链接的解绑设备与别名的绑定关系
:
http://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/
var x = new Notification { Alert = systemNotify.Alert, Android = { Title = "" } }
如果不要Android属性,则没有报null异常,但是如果是加上下面Android的这个属性就会报异常。
sdk版本号1.0.7
出现问题的操作系统版本:Windows XP professional 版本2002 sp3 (测试了XP机器)
使用的jpush api版本:jpush-api-csharp-client-3.3.1
接口调用异常:The underlying connection was closed: An unexpected error occurred on a send。
调试发现是向https://api.jpush.cn/v3/push发送post请求时出现异常,我测试了其它的https的url,比如百度的https://www.baidu.com 不会报上述异常,网络大部分关于“The underlying connection was closed: An unexpected error occurred on a send” 或者 “C# HttpRequest基础连接已经关闭: 接收时发生意外错误” 的解决方案都试了一遍,均无法解决上述问题。
sdk里边的模型如下:
public class SmsMessage
{
[JsonProperty("delay_time")]
public int DelayTime { get; set; }
[JsonProperty("temp_id")]
public long TempId { get; set; }
[JsonProperty("temp_para", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> TempPara { get; set; }
}
但是api要求有这些参数
关键字 | 类型 | 选项 | 说明 |
---|---|---|---|
delay_time | int | 必填 | 单位为秒,不能超过 24 小时。设置为 0,表示立即发送短信。该参数仅对 android 和 iOS 平台有效,Winphone 平台则会立即发送短信。 |
signid | int | 选填 | 签名ID,该字段为空则使用应用默认签名。 |
temp_id | long | 必填 | 短信补充的内容模板 ID。没有填写该字段即表示不使用短信补充功能。 |
temp_para | JSON | 可选 | 短信模板中的参数。 |
active_filter | boolean | 可选 | active_filter 字段用来控制是否对补发短信的用户进行活跃过滤,默认为 true ,做活跃过滤;为 false,则不做活跃过滤; |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.