[英]How to send push notifications to iOS devices using GCM on Java based application server
[英]How to send push notifications using java smack library + openfire server on web app,Android,IOS
我已经设置了openfire服务器,并希望通过Java后端服务器在webapp,Andriod和ios上发送推送通知。即,如果我通过java在openfire上发送推送通知消息,则它应该能够在连接的应用程序上发送通知。
据我所知,还没有适用于Firefire之类的支持Push通知的Openfire插件。
您的问题的解决方案可能是后台服务。 该服务将在后台运行,并为您的应用程序接收节。 该解决方案的缺点还在于电池寿命,因为您的服务在后台不断运行。
您的服务可以从应用程序启动,也可以从诸如BootReceiver,NetworkReceiver,ShutdownReceiver等接收器启动。
public class MessageService extends Service { }
可以说NetworkReceiver启动您的处理Stanza的服务,例如Message或PResence数据包:
public class NetworkReceiver extends BroadcastReceiver {
public static final String EXTRA_DATA_NAME_NETWORK_CONNECTED = "my.package.name.NetworkConnected";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
Intent serviceIntent = new Intent(MessageService.ACTION_NETWORK_STATUS, null, context, MessageService.class);
serviceIntent.putExtra(EXTRA_DATA_NAME_NETWORK_CONNECTED, NetworkUtils.isNetworkConnected(context));
context.startService(serviceIntent);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.