shalanah / inapp-spy

Detect in-app browsers
https://www.npmjs.com/package/inapp-spy
MIT License
23 stars 1 forks source link

Detect Telegram in app browser #30

Open mujeebcpy opened 23 hours ago

mujeebcpy commented 23 hours ago

Describe the bug Telegram in app browser is not being detected. the static svg is downloading id happening But blob svg not downloading. Also escape link also not working.

To Reproduce open https://inappdebugger.com/ from telegram chat.

Expected behavior Should detect it is viewing from telegram. And external browser should open when i click escape link.

Screenshots Screenshot_2024-10-16-00-32-18-62_0b342c26d6c44f3c8d2de40eabb4e1da Screenshot_2024-10-16-00-32-25-02_0b342c26d6c44f3c8d2de40eabb4e1da

shalanah commented 22 hours ago

@mujeebcpy Had same issue on my device. I'm not sure but maybe could detect on the odd 6668.100 string in the UA?

shalanah commented 22 hours ago

UA for future ref: Mozilla/5.0 (Linux; Android 14; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.100 Mobile Safari/537.36

shalanah commented 22 hours ago

I'm not sure what uses that Chrome build but on the window there is a property called TelegramWebview that we could maybe count on.

mujeebcpy commented 22 hours ago

we may detect inapp. But the current escape link is not working. So how to overcome that ? @shalanah

shalanah commented 22 hours ago

@mujeebcpy Excellent point.

I'll have to do a bit more research to see if there are other ways to exit Android in-app browsers or if the intent link needs to be formatted differently.

If that comes up short - you might want to do specific UI for Telegram that tells the user to click on the 3 dots or directions to open in their default browser instead.

shalanah commented 21 hours ago

@mujeebcpy Do you have better luck with this url scheme?

`intent://${urlhere}#Intent;scheme=https;end` 
ie: intent://example.com#Intent;scheme=https;end
shalanah commented 16 hours ago

Inappdebugger testing branch: https://deploy-preview-7--inappdebugger.netlify.app/

mujeebcpy commented 5 hours ago

yes. this opens the default browser. thank you. @shalanah found a way to detect it?

shalanah commented 4 hours ago

UA Android:

UA for future ref: Mozilla/5.0 (Linux; Android 14; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.100 Mobile Safari/537.36

UA iPhone:

Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Mobile/22B5045g Safari/604.1

mujeebcpy commented 4 hours ago

https://github.com/TelegramMessenger/Telegram-iOS/issues/736

seems there is an unsolved issue from 2022. users actively asking progress

shalanah commented 4 hours ago

@mujeebcpy I could just add detection for Android, for now, since most people use this library to make downloads work. But if others want to escape for other reasons like user sign in etc I might need to add some return properties about download capabilities of the latests builds only for blob urls and static assets. Any thoughts?

shalanah commented 3 hours ago

Here's my thoughts on how to proceed. Add an exclude parameter to InAppSpy that takes an array of inapp browsers to ignore ie:

InAppSpy({
  exclude: [{
    appKey: 'telegram', 
    brand: 'apple' // or 'android' or 'all' if left blank assumed 'all'
  }] // since downloads seem to work for now on this
})

This decouples the problems of in-app versions and me having to track in this repo which in-app browsers are problematic (which most are). I'll suggest a good excludes array in the documentation for those who care about current downloading capabilities.

shalanah commented 3 hours ago

Maybe even better is I have that functionality, but I give the user the ability to us the default includes...

InAppSpy({
  include: 'all' // or 'recommended' - blobUrls or static downloads fail, 'static' - static downloads fail
})
shalanah commented 47 minutes ago

For now I'm going to add Telegram just for Android and later add it for iOS with some of the includes ideas above since downloads work on that platform.

See #31