我已通过“Urban Airship”成功实施推送通知到我的应用程序。但是,如果我的应用程序被打开或最小化,我只会收到通知。如果应用程序未运行,我怎样才能让应用程序收到这些通知? 这是我用来运行UA的代码:
public class MyApplication extends Application {
@Override
public void onCreate(){
AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
UAirship.takeOff(this, options);
PushManager.enablePush();
String apid = PushManager.shared().getAPID();
String model = android.os.Build.MODEL;
String ver = android.os.Build.VERSION.RELEASE;
Logger.info("My Application onCreate - App APID: " + apid);
Logger.info("My Application onCreate - MOBILE NAME: " + model);
Logger.info("My Application onCreate - EMAIL IS: " + getUsername());
Logger.info("My Application onCreate - ANDROID VERSION: " + ver);
PushManager.shared().setAlias(getUsername() + "-" + model + "-" + ver);
PushManager.shared().setIntentReceiver(IntentReceiver.class);
}
答案 0 :(得分:0)
我认为您需要实现一项服务,以便独立于应用程序状态始终保持倾听。