我对android编码还不熟悉,但我已经玩过java了。
我想打开或带回我的应用程序,一旦它是在后台。
我到处找了找,但似乎什么都没用。
我有一个类的函数,它在每次收到通知时都被调用,它是cordovanotificationreceivedhandler,由onesignal init按照下面的代码示例化。
OneSignal.init(this.cordova.getActivity(),
googleProjectNumber,
appId,
new CordovaNotificationOpenedHandler(notifOpenedCallbackContext),
new CordovaNotificationReceivedHandler(notifReceivedCallbackContext)
);
为了使我的应用程序重新排序和显示,即使用户在另一个应用程序中,我也做了以下更改:
OneSignal.init(this.cordova.getActivity(),
googleProjectNumber,
appId,
new CordovaNotificationOpenedHandler(notifOpenedCallbackContext),
new CordovaNotificationReceivedHandler(this.cordova.getActivity(), notifReceivedCallbackContext));
在接收推送通知时调用的函数体中,我添加了以下代码:
Intent it = new Intent("intent.my.action");
it.setComponent(new ComponentName(contextActivy.getPackageName(), MainActivity.class.getName()));
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
contextActivy.getApplicationContext().startActivity(it);
this.handleActivityLifecycleHandler();
科莫一级公寓ó这是一个修改çã收件人:
private class CordovaNotificationReceivedHandler implements NotificationReceivedHandler {
private CallbackContext jsNotificationReceivedCallBack;
private Context contextActivy;
public CordovaNotificationReceivedHandler(Context contextActivy, CallbackContext inCallbackContext) {
jsNotificationReceivedCallBack = inCallbackContext;
this.contextActivy = contextActivy;
}
@Override
public void notificationReceived(OSNotification notification) {
Log.w("Got here","Aqui");
Intent it = new Intent("intent.my.action");
it.setComponent(new ComponentName(contextActivy.getPackageName(), MainActivity.class.getName()));
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
contextActivy.getApplicationContext().startActivity(it);
this.handleActivityLifecycleHandler();
try {
CallbackHelper.callbackSuccess(jsNotificationReceivedCallBack, new JSONObject(notification.stringify()));
}
catch (Throwable t) {
t.printStackTrace();
}
}
}
问题是应用程序没有重新排序以应用或打开。
重要的是要记住,我假设应用程序应该是开放的。
暂无答案!
目前还没有任何答案,快来回答吧!