Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Intents looping repeatedly #125

Open
micahlt opened this issue Feb 9, 2021 · 4 comments
Open

Intents looping repeatedly #125

micahlt opened this issue Feb 9, 2021 · 4 comments

Comments

@micahlt
Copy link

micahlt commented Feb 9, 2021

This plugin works perfectly and I thank you so much for it!

However, I'm experiencing some issues with intents occurring multiple times. My context is an unofficial mobile client for the children's programming site Scratch. I'm using this plugin to offer users the opportunity to forward links from the Scratch website directly to the app. Opening with my app works fine, but when you select "Open with Chrome", the "open with" popup appears up to four or five times before it finally opens the site. Any ideas of what could be causing this? Here's my only implementation of your plugin:

import {
  isPlatform
} from '@ionic/vue';

if (isPlatform('android')) {
      try {
        window.plugins.intentShim.onIntent(function(intent) {
          let uri = utils.matchRegexes(intent.data);
          if (uri.type == "homepage") {
            return 0;
          } else if (uri.type == "project" || uri.type == "studio") {
            window.location.replace(`/tabs/tab1?${uri.type}=${uri.id}`);
          }
        });
      } catch {
        console.error('Could not find Android Intent Shim plugin - see https://ionicframework.com/docs/native/web-intent');
      }
    }
@darryncampbell
Copy link
Owner

Hi, are you able to debug your code and determine if / why https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/blob/master/src/android/IntentShim.java#L642 is being invoked multiple times? That onIntent() method should just map to https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent) but I see logic in the code related to deferred / delayed firing so it is possible something is going wrong there.

@KoenLav
Copy link

KoenLav commented Dec 20, 2021

This may be related: we are experiencing startActivityForResult firing multiple times (on some occasions).

@darryncampbell
Copy link
Owner

@KoenLav are there reproducible reproduction steps?

@KoenLav
Copy link

KoenLav commented Dec 20, 2021

I'm now thinking it may have to do with us not providing a requestCode, because of which 1 is used by default, but it seems requestCode is like an 'Intent identifier' rather than 'just' the code it returns.

Testing that theory now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants