I'm building an App with Cordova and right now I'm focussed on a Background Service. I need that Service for Notifcations and to update them regularly, which is working quite well already. When a user clicks on the notification, it should open the app, just like with Spotify for example. Now with a standalone App, I would usually just do it like this:
Intent intent = new Intent(this, MyActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent contentIntent = PendingIntent.getActivity(this,0,
intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, myChannelID)
.setContentIntent(contentIntent);
And then build the notifcation and so on. The problem is, that I am not able to access the Cordova Activity from within the service. I've tried something like this:
Intent intent = new Intent(this, MyPlugin.class);
But as the Plugin does not extend activity (it extends CordovaPlugin) this does not seem to work. I can access the activity from within the Plugin, but I can't seem to be able to pass the activity to the service. Any help would be appreciated :).