server side:Android Push Notification | Free Communications software downloads at SourceForge.net
client with b4a:
activity:
service:
And we should add the inside service to the manifest editor:
Before them you must download my library pushlib
to use this,you must make the appkey in b4a code and server are the same.
that's all enjoy yourself
client with b4a:
activity:
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim startbtn,stopbtn As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
startbtn.Initialize("btn")
startbtn.Text="StartListen"
stopbtn.Initialize("btn")
stopbtn.Text="StopListen"
Activity.AddView(startbtn,20dip,10dip,120dip,50dip)
Activity.AddView(stopbtn,20dip,70dip,120dip,50dip)
End Sub
Sub btn_Click
Dim btn As Button
btn=Sender
If btn.Text="StartListen" Then
StartService(ser)
Else
StopService(ser)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
B4X:
'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim push As PushLib
Dim notify As Notification
End Sub
Sub Service_Create
push.StartService("push","1234567890","192.168.99.100","5222",push.sym_action_chat)
End Sub
Sub push_onnotify(appid As String,title As String,body As String,uriStr As String)
notify.Initialize
notify.Icon="icon"
notify.SetInfo(title,body,Main)
notify.Sound=True
notify.Light=True
notify.AutoCancel=True
notify.notify(0)
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_Destroy
push.StopService
End Sub
B4X:
AddApplicationText(
<service android:enabled="true"
android:name="com.NotificationService"
android:label="NotificationService">
<intent-filter>
<action android:name="org.androidpn.client.NotificationService" />
</intent-filter>
</service>)
to use this,you must make the appkey in b4a code and server are the same.
that's all enjoy yourself