Android push notification (Android client information push) (androidpn-server and androidpn-client)

Source: Internet
Author: User
Tags android push notification


| Font size subscription

As mentioned in the previous blog, information push is implemented in Android. One of the more mature solutions is implemented using XMPP protocol. The androidpn project is an open-source project that uses the XMPP protocol to push information. Here we will introduce how to use it.

 

Features of apndroid push notification:

Quick integration: provides a faster way to use than c2dm, avoiding various restrictions.

No Server SETUP required: reduces the extra server load by using cloud services.

Push messages to the website page at the same time, Android mobile phone

Low Power Consumption and low traffic consumption.

 

Specific configuration process:

First, download androidpn-client-0.5.0.zipand androidpn-server-0.5.0-bin.zip.

: Http://sourceforge.net/projects/androidpn/

 

Decompress the two packages, import eclipse to the client, configure the target platform, open the raw/androidpn. properties file, and configure the client program.

 

1. if a simulator is used to run the client program, configure xmpphost to 10.0.2.2. [The simulator considers 10.0.2.2 as the address of the host, 127.0.0.1 as the loopback address of the simulator, and 10.0.2.1 as the gateway address, 10.0.2.3 indicates the DNS address, and 10.0.2.15 indicates the network address of the target device.] For more information about simulators, see related information.

Xmppport = 5222 is the XMPP service listening port of the server.

 

Run androidpn-server-0.5.0 \ bin \ Run. bat starts the server and accesses http: // 127.0.0.1: 7070/index from the browser. do (androidpn server has a lightweight web server that listens to requests on port 7070 and receives text messages from users)

 

When the client runs, the client initiates a connection request to the server. After successful registration, the server can identify the client and maintain a persistent connection with the client's IP address.

 

2. if it is a simulator test of another machine in the same LAN (or a real machine using the same wireless router WiFi), you need to set this value to the lan ip address of the server machine.
 

For example, your computer and Android phone both use the same wireless router wifi to access the Internet. The IP address of the computer is 192.168.1.2 and the IP address of the mobile phone is 192.168.1.3. In this case, you need to change the value to xmpphost = 192.168.1.2, you can use it on your mobile phone.

 

3. If it is a real machine test that is not in the same LAN, we need to set this value to the IP address of the server.

 

The specific configuration is shown in:


 

My computer ip address is 192.168.8.107

 

Main server running interface:

 


 

 

 

Push information:


The test result is as follows:


 


 


The simulator and the real machine pass the test.

Note: When the Client Session list shows that there is no client, but the client has actually started, it may be a network problem. We need to wait for a while and observe the relevant logs through ADB logcat.

 


 

Other usage procedures:

Of course, the above is to configure and implement information push on your own server. If you want to save time, we recommend a website here to make it easier to implement push, the disadvantage is that you need to use someone else's server. You know about this.

URL: http://www.push-notification.org/

You only need to apply for an API.


Other push solutions will be introduced in a later blog.

Complete.


This article is through the jetty framework to build the Background Service, through tomcat to build the background service, see the http://www.apkbus.com/android-48367-1-1.html


This article is reproduced in: Android push notification for Information Push

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.