Umeng pushes. NET (C #) server SDK rest api call library,

Source: Internet
Author: User

Umeng pushes. NET (C #) server SDK rest api call library,
Introduction to the rest api of umeng push. NET SDK

This version is encapsulated based on the 2.3 version pushed by umeng. It is not found on the Internet. the NET version of the call library is not officially encapsulated. only python, java, and php are supported. so I shared a simple and easy-to-call version to share with you. The encapsulated code is much simpler than the encapsulated [Xin Ge push] and has a high degree of freedom, parameters are basically directly converted to json object, need according to umeng rest api http://dev.umeng.com/push/android/api-doc to specific assignment, so get the source code is also easy to modify josn object entity, call object only 2 methods

// Synchronous submission
Public ReturnJsonClass SendMessage (PostUMengJson paramsJsonObj) // asynchronously submits public void AsynSendMessage (PostUMengJson paramsJsonObj, Action <ReturnJsonClass> callback)

How easy is it !!

 

Before calling push, you must instantiate the push object of the subject.

1 UMengMessagePush umPush = new UMengMessagePush ("Your appkey", "Your appMasterSecret ");

In this way, you can place the required two configurations in web. config, or assign other configurations to the object without adding these two parameters for any subsequent push.

 

Example 1 of calling code (pushed to all users)

 

/// <Summary> /// push to all users /// </summary> [TestMethod] public void TestPushByAllUser () {PostUMengJson postJson = new PostUMengJson (); postJson. type = "broadcast"; postJson. payload = new Payload (); postJson. payload. display_type = "notification"; postJson. payload. body = new ContentBody (); postJson. payload. body. ticker = "comment reminder"; postJson. payload. body. title = "your comments have replied"; postJson. payload. body. text = "your comment Let's talk about some replies ..... "; PostJson. payload. body. after_open = "go_custom"; postJson. payload. body. custom = "comment-policy"; postJson. description = "comment reminder-UID:" + 123; postJson. thirdparty_id = "COMMENT"; ReturnJsonClass resu = umPush. sendMessage (postJson); // umPush. sendMessage (postJson, callBack); Assert. areEqual (resu. ret, "SUCCESS", true );}
Example 2 of calling code (asynchronous push based on user ID)

 

/// <Summary> /// push Based on the Custom User ID /// </summary> [TestMethod] public void TestPushByAlias () {PostUMengJson postJson = new PostUMengJson (); postJson. type = "customizedcast"; postJson. alias_type = "USER_ID"; postJson. alias = "5583"; postJson. payload = new Payload (); postJson. payload. display_type = "notification"; postJson. payload. body = new ContentBody (); postJson. payload. body. ticker = "comment reminder Alias"; post Json. payload. body. title = "your comments have replies"; postJson. payload. body. text = "Alias your comments have replies ..... "; PostJson. payload. body. after_open = "go_custom"; postJson. payload. body. custom = "comment-policy"; postJson. thirdparty_id = "COMMENT"; postJson. description = "comment reminder-UID:" + 5583; // ReturnJsonClass resu = umPush. sendMessage (postJson); umPush. asynSendMessage (postJson, callBack);} private void callBack (ReturnJsonClass result) {ReturnJsonClass a1 = result ;}

 

 

Open Source Code address

Https://github.com/jasnature/NSTool.UMengPush

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.