Share EncyclopediaHome EncyclopediaCategories Switch Channel

Unipush to complete service delivery in the notification bar for un-app

2026-02-28 07:051150NameNetworking

Background

It's a matter for the official to provide the document, but the official thought it was superfluous. So i'm here to describe the steps taken to implement the circular。

Un-app official document entry

Https://uniapp. Dcloud. Io/api/plugins/push

Unipush official usage guide

Https://ask. Dcloud. Net. Cn/article/3562

Send h5+api interface:

Https://www. HTML5plus. Org/doc/zh cn/push. HTML

Basic environmental readiness 2. 1 dcloud platform configuration

Reference is made to the official curriculum for the deployment of api and secret from the various manufacturers in dcloud, which is not a difficult part of the story, and there is a message。

Https://ask. Dcloud. Net. Cn/article/35716

Message delivery service

Why should we configure the manufacturer:

In order to be able to send messages to the mobile phone notification system via the manufacturer's server when app is closed. Third-party transmissions are blocked, and the best way to do so is to access the delivery services at the request of the manufacturer. Fortunately, this part of dcloud has done you a favor. All you have to do is register the developers' development platforms and press the appid and secret to access the dcloud backstage。

Message delivery service

2. 1 un-app permission configuration

Message delivery service

2. 3 ready to customize test bases or cloud packs

Hbilder's base is configured with dcloud information, so it's impossible to test the delivery service with a personal app. There are two kinds of solutions

One, pack up when the clouds are packed and become a post-app test

Two, create a self-defined base, which is very simple

When running, choose to customize the base seat or install apk directly after the cloud is packed to a mobile phone test。

That's all we need

3 experience sending (helping to understand the process) 3. 1 app end code

The code position can only be found in anonlaunch at app. Vue, where there may be problems elsewhere。

/ #ifdef app-plus
varinfo = plus. Push. Getclintinfo();
console. Log (json. Stream(info));

plus. Push. Addeventlistener("click", funcing(msg){
(a) console. Log ("click:"+json. Stringify(msg));
(b) console. Log (msg. Payload);
console. Log (json. Stream(msg));
/ here you can write jump codes
}, false);
// listen to online news events
plus. Push. Addeventlister
/ plus. Ui. AWhat are you doing here?
/ here you can write jump codes
"recevice:"+json. Stringify(msg)
}, false);
#indif

This is where the official documents are disgusting, where their own life, onpush, or api, is abandoned, but the demo is still abandoned. The recommended h5+api is not given to demo. You know, demo is the api file for us。

There's two kinds of events that listner listens to

The method above is based on the basic code at the end of the app, which enables the ability to obtain information from the delivery centre. Concrete ways to achieve this can be avoided。

3. 1 test messaging (no server code required)

Open dcloud's backstage, open the message for distribution, fill in the message and click on the preview

Message delivery service

The cid that was filled here is the clitid that was retrieved in the app code segment, and the post-review system hint was sent successfully。

Varinfo = plus. Push. Getclintinfo();
console. Log (json. Stream(info));

Message delivery service

Note:

The cell phone must be either a cloud pack or a self-defined base app to fill in the correct message id, which locates your cell phone and can be understood as the ip. You're gonna have to wait until the server end code java step 1: a push-sdk import

I don't knowGexin-rp-sdk-http4. 1. 0. 5Get-nexusHttp://mvn. Gt. Igexin. Com/nexus/content/repository/releases/

A simple version of java

This equivalence can be achieved with the following code:。

II'm sorryIt's not a good idea, is it? II'm sorryIt's not like i'm going to have to do this. IIgtpush;
iNotiontemplate;
iI don't know. IIoexception;
iI don't know. II don't know. The public class pushtest
/ step 1: access to basic information on applications
= """;
= """;
= "";
"http://sdk. Open. Api. Igexin. Com/apix. Htm";
public status vaid mine (stringargs) throws ioexception
igtpush = new igtpush (url, appkey, mastersecret);
syle0 syle = new syle0();
/ step2: sets to transfer the title, the content
(a) "syle. Settile" ( "please enter the title of the notice bar");
(a) "syle. Settext" ( "please enter the contents of the notice bar");
syle. Setlogo("push. Png"); / /sets out icons
/ / step3: set up bells, vibrations, etc.
/ set the bell
/ set vibrate
/ step4: selection of notification template
notificatio= new notificatioNtemplate();
template. Setappid;
template. Setappkey;
i don't know, template. Setstyle.
/ step5: define the "appmessage" type message object, set the extension parameters for the delivery of the message, etc. ListI'm sorry(a) (a) (ii);
(b) appids. Add;
appmessage message = new appmessage();
i don't know what to do. I don't know what to do with it.
(c) message. Setoffice;
msage. Setoverlineexpiretime (1000 * 600); / / time units in milliseconds
/ / step6: execute delivery
ipushresult ret = push. Pushmassagetoapp;
system. Out. PrindlnNse(). Tostrring());
♪ i'm sorry ♪
♪ i'm sorry ♪

Reference documents

Dcloud is entirely dependent on a push, so a push-up official document is fully applicable in the uniapp push module。

Like 0
Report
Favorite 0
Tip 0
Comment 0
Share 3
MoreRelated Comments
No comments yet, be the first to comment