Hubilder Packaging +c# Service implementation of the end-push service

Source: Internet
Author: User

On the push to tinker for a long time, here no longer write HelloWorld, only talk about the problems encountered inside.

1. About registration on the Apple developer platform

Many tutorials on the web, just follow the steps to set up on the line, in the iOS certificate (. p12) and profile (. mobileprovision) Application This article is very clear, the article also shows that if you want to use the push function, then in the application of the AppID to choose "Push Notifications "this option. This article is very detailed and summarizes the following points

1. Apply for Apple AppID, the certificate in an app is based on this AppID
2. Generate a certificate request file that must be generated on an Apple computer, The suffix of the file is. Certsigningrequest, which is used later to generate the certificate file, which is generated with the Certificatesigningrequest.certsigningrequest file Ios_ Development.cer file
3. Generate the development certificate, here is to generate the Ios_development.cer file, and then the file on the Apple Computer Kenchain access to export. P12 certificate file
4. Add a debug device , this is mainly to collect the test to add the UUID to the developer platform Devices list, the subsequent generation of the certificate description file used when the device
5. Application Development (development) profile, here to select the previous AppID, select the added device, Finally, a development.mobileprovision file is generated
6. Generate the Publish certificate, this is mainly for the shelves, and step 3 The only difference is the type of choice is different, the former is development the following iOS App Development, the latter is production under the app Store and Ad hot, also choose Step 1 generated AppID, but there is no choice of equipment, all shelves, but also choose the device is not right.

Note that this article is not rigorous, when creating AppID "in the" Explicit app id "column under the" Bundle ID "entry to enter the APP ID (using the Reverse Domain name format string, such as" io.dcloud.HBuilderApp "):" in " Application Development (development) certificate and description file "and" Application for publishing (distribution) certificate and description "when the landlord wrote:" Click on the "Continue" button, open the "app id" Selection page, select the "app ID" to use (as previously created "IO.DCLOUD.HBUILDAPP"), click "Continue": "Io.dcloud.HBuilderApp and io.dcloud.HBuildApp obviously not the same, they are one thing, do not be bewitched by it." It is important to note that this article does not mention how to generate a push certificate, although you are prompted to choose the Push feature when you generate AppID in step 1, you also need to generate a push certificate to upload to a push platform, which is not mentioned throughout the article.

2. Generate a push certificate

The above questions can be found on a push developer platform, Apple APNs configuration, here also described the creation of the Apple app ID, this and the first cloth generated by the app ID is one thing, do not repeat the generation, also said to select the push notifications, In the second session, we talked about creating a APNs push certificate, which is very critical, similar to generating a publishing certificate above, and it also uses the Certificatesigningrequest.certsigningrequest file generation Ios_push_ Development.cer This file, then use this file to export the IOS_PUSH_DEVELOPMENT.P12 certificate file, and finally upload the certificate to a push application platform. Such as:

Note The third step of this article "Provisioning profile creation" is very fascinating, come up with a "create a Com.igexin.getui.demo AppID, and configure Push notifications for this AppID", Don't be fooled by it is the above step 1, the remaining steps and the above step 5: "Application Development (development) profile" no difference. In short, for an app as long as the use of AppID, are the same.

3. About Platform Configuration

There's nothing to say here, after configuring an app on a push-down platform, fill in the Hbuilder Manifest.json file with a push-appid,appkey,appsecret.

4. About ClientID

The rest of the time is to go to a push platform to download a server demo, I use the C # version, when you experiment with the first example of Pushmessagetoapp () such a method, this is sent to a app,clientid, Note must be packaged after obtaining this clientid, can not be obtained in the debug state, that is, can not be in the hbuilder inside this, and then use Console.log print out in hbuilder copy.

Be sure to pack it up and pop it out with alert, then one by one, and put it in the C#demo program. As follows:

5. About sending to a specific user group

In the first example of the demo, the Hand Pushmessagetoapp () method in the body of the

This sentence to open the comment, the results are not received, note that this is required to first use Push.setclienttag this method to set up in accordance with the user tags to send, if the user does not have this tags will not receive the push. It would be nice to comment out this sentence.

6. About the transmission message +apns

The iOS system seems to be only +apns pushed using the transmissiontemplate template, so when building a pass-through message template, add the following paragraph:

            //APN Advanced Push StartApnpayload apnpayload =Newapnpayload (); Dictionaryalertmsg alertmsg=Newdictionaryalertmsg (); Alertmsg.body="Body"; Alertmsg.actionlockey="Actionlockey"; Alertmsg.lockey="Lockey"; Alertmsg.addlocarg ("Locarg"); Alertmsg.launchimage="Launchimage"; //iOS8.2 Support FieldsAlertmsg.title ="Title"; Alertmsg.titlelockey="Titlelockey"; Alertmsg.addtitlelocarg ("Titlelocarg"); Apnpayload. Alertmsg=alertmsg; Apnpayload. Badge=Ten; Apnpayload. Contentavailable=1; //Apnpayload. Category = "";Apnpayload. Sound ="Test1.wav"; Apnpayload.addcustommsg ("Payload","Payload");            Template.setapninfo (Apnpayload); //APN Advanced Push End

The whole method looks like this after it's been added:

        //Through- Pass template action content         Public Statictransmissiontemplate Transmissiontemplatedemo () {transmissiontemplate template=Newtransmissiontemplate (); Template. AppId=APPID; Template. AppKey=APPKEY; //app Startup type, 1: Force app Launch 2: Wait for app to startTemplate. Transmissiontype ="1"; //Pass ContentTemplate. Transmissioncontent ="Pass Content"; //set the notification timing display time, the end time differs from the start time by more than 6 minutes, after the message is pushed, the client will display the message within the specified difference (Error 6 minutes)//String begin = "2017-03-13 00:36:10"; //String end = "2017-03-13 23:46:20"; //template.setduration (begin, end); //APN Advanced Push StartApnpayload apnpayload =Newapnpayload (); Dictionaryalertmsg alertmsg=Newdictionaryalertmsg (); Alertmsg.body="Body"; Alertmsg.actionlockey="Actionlockey"; Alertmsg.lockey="Lockey"; Alertmsg.addlocarg ("Locarg"); Alertmsg.launchimage="Launchimage"; //iOS8.2 Support FieldsAlertmsg.title ="Title"; Alertmsg.titlelockey="Titlelockey"; Alertmsg.addtitlelocarg ("Titlelocarg"); Apnpayload. Alertmsg=alertmsg; Apnpayload. Badge=Ten; Apnpayload. Contentavailable=1; //Apnpayload. Category = "";Apnpayload. Sound ="Test1.wav"; Apnpayload.addcustommsg ("Payload","Payload");            Template.setapninfo (Apnpayload); //APN Advanced Push End            returntemplate; }

This is introduced on a push platform, but it's a bit cryptic. C # push template, as follows:

All right, so much more, and if you see something wrong there, you want to point it out. Thank you!

Hubilder Packaging +c# Service implementation of the end-push service

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.