carsten-klaffke / send-intent

Repository for send-intent Capacitor plugin
MIT License
106 stars 12 forks source link

[Android] Receive multiple intent data until app hangs and App Crash after calling finish #84

Closed wheel1992 closed 1 year ago

wheel1992 commented 1 year ago

@carsten-klaffke

Describe the bug

2 issues are happening

Issue 1

Receiving multiple intent data after sharing one content. However, in iOS, iOS receive only one intent event per shared content which works as expected.

File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.666 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.677 27118-27118 Capacitor/Plugin        gg.republik.app.dev                  V  To native (Capacitor plugin): callbackId: 13970433, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.680 27118-27118 Capacitor               gg.republik.app.dev                  V  callback: 13970433, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.702 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.702 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.704 27118-27118 Capacitor/Plugin        gg.republik.app.dev                  V  To native (Capacitor plugin): callbackId: 13970434, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.704 27118-27118 Capacitor               gg.republik.app.dev                  V  callback: 13970434, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.705 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.706 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.707 27118-27118 Capacitor/Plugin        gg.republik.app.dev                  V  To native (Capacitor plugin): callbackId: 13970435, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.707 27118-27118 Capacitor               gg.republik.app.dev                  V  callback: 13970435, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.711 27118-28139 Capacitor/Plugin        gg.republik.app.dev                  W  getObject calls without a default value will return null in Capacitor 5 instead of an empty object to match iOS behavior
2023-08-25 11:30:03.711 27118-28139 Capacitor/Plugin        gg.republik.app.dev                  W  getObject calls without a default value will return null in Capacitor 5 instead of an empty object to match iOS behavior
2023-08-25 11:30:03.713 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.714 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.715 27118-27118 Capacitor/Plugin        gg.republik.app.dev                  V  To native (Capacitor plugin): callbackId: 13970436, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.715 27118-27118 Capacitor               gg.republik.app.dev                  V  callback: 13970436, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.716 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.716 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.716 27118-27118 Capacitor/Plugin        gg.republik.app.dev                  V  To native (Capacitor plugin): callbackId: 13970437, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.716 27118-27118 Capacitor               gg.republik.app.dev                  V  callback: 13970437, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.717 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.717 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.718 27118-27118 Capacitor/Plugin        gg.republik.app.dev                  V  To native (Capacitor plugin): callbackId: 13970438, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.718 27118-27118 Capacitor               gg.republik.app.dev                  V  callback: 13970438, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.718 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.719 27118-27118 Capacitor/Console       gg.republik.app.dev                  I  File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false

Issue 2

App crash after calling SendIntent.finish()

// AndroidManifest.xml
<application>
  ...
  <activity
      android:name="de.mindlib.sendIntent.SendIntentActivity"
      android:label="RepubliK"
      android:exported="true"
      android:theme="@style/AppTheme">
      <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <action android:name="android.intent.action.SEND_MULTIPLE" />

        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
        <data android:mimeType="image/*" />
        <data android:mimeType="video/*" />

      </intent-filter>
    </activity>
   ...
</application>
const checkIntent = async () => {
    console.log('checkIntent')
    return SendIntent.checkSendIntentReceived()
      .then(async (result?: ShareReceiverIntentResult) => {
        console.info(
          'SendIntent.checkSendIntentReceived result',
          JSON.stringify(result)
        )

         // Other logic
         // ....

         SendIntent.finish()
      })
      .catch((err) => console.error(err))
  }

Smartphone (please complete the following information):

carsten-klaffke commented 1 year ago

Issue 1: Please show me how you call "checkIntent". In my own code, it looks like this: useEffect(() => { window.addEventListener("sendIntentReceived", () => { checkIntent(); }); checkIntent(); }, [])

Issue 2: Please have a look at 69!

wheel1992 commented 1 year ago

Thank you @carsten-klaffke