Other B4X Push Server

B4X Push Server is a B4J written back-end server for B4i and B4A apps that use push notifications (Android - GCM, iOS - APN).

Its two main features are:
- Collect device tokens - DeviceToken class.
- Send messages to the devices - Send servlet (which calls iOSPush and AndroidPush modules).

Configuration

There are several settings which you need to configure. The configuration file is located under the Objects folder:

SS-2014-12-24_10.56.25.png


You must set the following properties:
iPushKeyStore / iPushKeystorePassword - Path and password of the push keystore created with B4i (see this tutorial: https://www.b4x.com/android/forum/threads/push-notifications.48562/).

AndroidApiKey - The GCM key from Google developer console (see this tutorial: https://www.b4x.com/android/forum/threads/19226/#content).

PushServerPassword - This value is required when sending messages.

B4A / B4i Apps

The B4A / B4i apps that receive push notifications (client apps) need to register to the push notifications service when they start and send the received token to the B4X push server. You need to configure the push server url in each of the apps.

For the B4A app you need to set the SenderId and to add the required text to the manifest editor.

For the B4i app you need to set the #ProvisionFile attribute to point to the push provision profile.

Server Code

The server code is quite simple and can be customized as needed. It depends on jNetwork library v1.10+ (for the SSLSocket).
The tokens are stored in a SQLite database.

To send a message to all devices (that were updated in the last 3 days) you need to call the Send servlet:
http://<server url>/send?password=<PushServerPassword>&text=Message to send

Apple remote notifications documentation: https://developer.apple.com/library...icationsPG/Chapters/CommunicatingWIthAPS.html
Google GCM documentation: http://developer.android.com/google/gcm/index.html


V0.96 - Fixes an issue with the feedback timer being disabled.
V0.95 - It adds support for iOS feedback service. These lines should be added to existing config files:

#change to: feedback.push.apple.com for production
iFeedback=feedback.sandbox.push.apple.com
iFeedbackPort=2196

The feedback service holds a list of rejected tokens. The server will call it once an hour to find rejected tokens which will then be deleted from the database.

Note that the feedback service isn't working properly in sandbox mode (the problem is in Apple servers).
 

Attachments

  • B4i-PushClient.zip
    3.1 KB · Views: 1,513
  • B4A-PushClient.zip
    7.5 KB · Views: 1,974
  • PushServer.zip
    13.3 KB · Views: 1,547
Last edited:

abhishek007p

Active Member
Licensed User
Longtime User
I don't plan to port it to PHP.

what is the requirement to run this B4x server?..

can i just upload it to my web hosting (shared hosting)? if that is not possible then a PHP port of iOS push server (like what you did on android push server) would be needed.
 

fbritop

Active Member
Licensed User
Longtime User
I have been using the B4X Push Server. But now my database of users has grown, I have detected the status 8 (bad token) with an important number of users, maybe they have uninstall the app or change device,

Is there anyway I can capture the token when the status is returned?

I mean during:

B4X:
Private Sub astream_NewData (Buffer() As Byte)
    If Buffer.Length >=6 Then
        Dim bc As ByteConverter
        Log("status=" & Buffer(1))
    Else
        Log("Invalid response")
    End If
End Sub

So after I know which token gave me status 8, I can manipulate my database in order to clear the token because it is invalid.

Thanks
FBP
 

kreativa

Member
Licensed User
Longtime User
Hi,

Just a question?
What i have to do to deploy pushserver on my webserver IIS7?

Thanks
 

kreativa

Member
Licensed User
Longtime User
Hi,
i have to deploy it on my IIS7 server with tom cat installed
Is it possible? How i can do?
Thanks
 

moster67

Expert
Licensed User
Longtime User
Just got myself a VPS running CentOS. To run the b4x push server (and other apps created with B4J), is it enough to install the Runtime environment of Java or do I need to install JDK? Which version of Java do you recommend?
 

kreativa

Member
Licensed User
Longtime User
i receive an errore message:
Error connecting socket: (EOFException) java.io.EOFException: SSL peer shut down incorrectly
java.lang.UnsupportedOperationException: The method shutdownInput() is not supported in SSLSocket

why?

Thanks
 

kreativa

Member
Licensed User
Longtime User
sorry i'don't understand how i can install the push server on my webserver.
Which files i must copy on my webserver? i need to install b4j on my server?
Please tell me the steps i have to do to run push server on my webserver.

Thanks so much!
 

moster67

Expert
Licensed User
Longtime User
The B4x Pushserver is now using the same port (currently 51044) and uses the handlers 'send' and 'devicetoken' to deal with incoming and outgoing requests. If the volume of traffic increases, would it be better to add a new server-object and create new handlers and another port?
 

kreativa

Member
Licensed User
Longtime User
thanks,
i've installed the server and it runs.
But i always receive the error:
Error connecting socket: (EOFException) java.io.EOFException: SSL peer shut down incorrectly
java.lang.UnsupportedOperationException: The method shutdownInput() is not supported in SSLSocket
why?
 
Top