小编Mar*_*hes的帖子

从 Android 意图打开 Ionic(电容器)应用程序中的特定页面

我有一个使用 Ionic 4 和 Capacitor 编写的 Web/Android 应用程序,我一直在尝试通过 Android 服务(通过电容器插件激活)发出的通知将 Ionic 应用程序重新输入到特定页面,但没有成功。

以下是在服务中创建通知的代码:

private Notification getNotification() {
    CharSequence contentTitle = "Fun App Background Mode Running";
    CharSequence contentText = "Fun App";
    long notificationTime = System.currentTimeMillis();

    if (_NFC == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            NotificationChannel channel = new NotificationChannel("funapp", "FunApp", NotificationManager.IMPORTANCE_DEFAULT);
            channel.enableLights(false);
            channel.enableVibration(false);
            channel.setSound(null,null);
            channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
            channel.setShowBadge(true);
            manager.createNotificationChannel(channel);
        }

        Intent notificationIntent = new Intent(this, MainActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addNextIntentWithParentStack(notificationIntent);
        PendingIntent pendingIntent =
            stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); …
Run Code Online (Sandbox Code Playgroud)

android android-intent ionic-framework ionic4 capacitor

5
推荐指数
1
解决办法
7470
查看次数