Prevent Chrome from Swallowing NFC Deep-Links - android

I have an Android test app set up to be opened from a Deep Link from NFC records. It works, but ONLY if Chrome is disabled. If Chrome is not disabled, it will not even ask, it will ONLY open Chrome.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="www.example.com"
/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="www.example.com"
/>
</intent-filter>
</activity>
</application>
</manifest>
As you can see, it is registered both for VIEW and NDEF_DISCOVERED actions. On VIEW actions (such as clicking on a link from Slack), it will ask if I want to open Chrome or my app. However, for NDEF_DISCOVERED actions, if Chrome is not disabled, it will just open Chrome directly. If Chrome is disabled, it will them ask about opening my app.
I have heard that this may be related to Android 10, but I didn't know if there was a permission I could request or something that would bypass this behavior. I am trying it out on a OnePlus 6T running Android 10.

Related

App icon doesn't appear after implementing deep links to my app

I'm developing an app in Android Studio it works pretty well, but after implementing deep links to my launching activity my app doesn't you the app icon in the menu, I know the app is installed cause in Setting>Applications it appears. I know the problem is in the manifest.xml, so I'll leave a copy down bellow.
I'll love to hear about your solutions, by the way if you are reading this thanks.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dev.misterj.nocherd">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permision.CALL_PHONE"/>
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyAiJNpq-********************" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="#xml/network_security_config"
android:theme="#style/AppTheme">
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "https://myapp.com/place” -->
<data android:scheme="https" android:host="myapp.com" android:pathPrefix="/place" />
<!-- Accepts URIs that begin with "myapp://place” -->
<data android:scheme="myapp" android:host="place" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
</manifest>
You should separate the intent filters, also your manifest file is not well-formatted. you should close the application tag. you can open it with an external application like google chrome, it will tell you if the XML is not in correct format.
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" android:host="place"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="myapp.com" android:pathPrefix="/place" />
</intent-filter>
</activity>
it's important that you create separate filters when your intention is to declare unique URLs (such as a specific combination of scheme and host) because multiple <data> elements in the same intent filter are actually merged together to account for all variations of their combined attributes. if you combine them it actually supports https://place and also supports myapp://myapp.com/place.
So you should separate them.

How can I open my React Native App from the browser?

I would like to open my app from the browser.
example: I open a browser, type in: https://open.my.app, or app://www.example.com and have my app as an option come up.
I read about Deep Links and I am quite sure I set up my project properly, YET nothing happens when I either try to type and run: https://open.my.app, app://www.example.com
My AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.somemobileapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Change these two in the future to a proper one -->
<data android:scheme="https" android:host="www.example.com" />
<data android:scheme="app" android:host="open.my.app" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
So even after this, it's not working.
I know it will sound strange but keeping the data tag on first worked for me
<intent-filter>
<!-- data on first -->
<data android:scheme="http" android:host="abc.in"/>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

Android app does not install with intent.action.VIEW

When I add an intent filter (to enable Google to crawl my app content and allow users to enter my app from search results) then my app still runs from Android Studio on my phone but it no longer installs.
My manifest is below, I have commented out the added intent filter to make it install again, so now I get a warning that it is not indexable by Google search.
What can I do so it installs and is indexable?
This is my first app so apologies if this is obvious but I appreciate any help. Thanks.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.somename.myappname">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<!--action android:name="android.intent.action.VIEW" /-->
<action android:name="android.intent.action.MAIN" />
<!--category android:name="android.intent.category.DEFAULT" /-->
<!--category android:name="android.intent.category.BROWSABLE" /-->
<category android:name="android.intent.category.LAUNCHER" />
<!--data android:scheme="somename"
android:host="myappname" /-->
</intent-filter>
</activity>
<activity android:name=".ChildActivity">
</activity>
</application>
</manifest>
I seem to have found the solution. There should be 2 separate intent filters ...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.mywebsite.com"
android:pathPrefix="/myappname" />
</intent-filter>

Listening for incoming links on Android with React-Native

I am able to listen and handle incoming links on IOS with react-native using the linking library: https://facebook.github.io/react-native/docs/linking.html, but it shows the function for adding an event listener for a url is IOS platform specific. Are there any other ways of listening for incoming links to my app on android and handling it on the Javascript side?
I just got it working! You just have to follow these instructions.
Basically, add an <intent-filter> under the existing one of your android/app/src/main/AndroidManifest.xml, containing the VIEW action, the DEFAULT and BROWSABLE categories, and at least a <data>.
Then simply rebuild and reinstall your APK (react-native run-android), that's it! Links matching your <data> tags will now open in your app!
Now just catch this URL with Linking.getInitialURL() in the componentDidMount() of your main Javascript class!
Example of manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.yourapp"
android:versionCode="1"
android:versionName="0.1">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:largeHeap="true"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- HERE: -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="yoursite.net" />
<data android:scheme="https" android:host="yoursite.com" />
<data android:scheme="https" android:host="yoursite" />
<data android:scheme="customscheme" android:host="yourpath" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>

intent filter for ical URLs

I'm trying to register my Android app as a handler for iCal URLs. To do this I set intent filters in my Manifest for the webcal:// pseudo protocol and for HTTP URLs using the text/calendar MIME type (see below).
This works perfectly fine in the emulator, but on a real device I'm having problems. The webcal:// filter works, but the text/calendar one doesn't. Instead the Browser displays the ical file as plain text instead of passing the URL to my app.
I checked that the browser isn't configured as a default handler for ical (in Settings->Applications->Browser) and I asked a few other people if they could reproduce the problem on their mobiles. All with the same result.
What's the correct way to register for text/calendar URLs?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.splitbrain.giraffe"
android:versionName="0.31" android:versionCode="4">
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name" android:theme="#android:style/Theme.Light.NoTitleBar">
<activity android:label="#string/app_name" android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.BROWSABLE"></category>
<action android:name="android.intent.action.VIEW"></action>
<data android:mimeType="text/calendar" android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.BROWSABLE"></category>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="webcal"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
<activity android:name="OptionsActivity"></activity>
<activity android:name="DetailActivity"></activity>
<activity android:name="AboutActivity"></activity>
</application>
</manifest>
Update: Turns out the above works fine in the Android 1.6 emulator, but not on a 2.3.3 emulator where it shows the same behavior as on my phone. Is this a bug in Android maybe?
I opened a bug report at https://code.google.com/p/android/issues/detail?id=18796
Just use the DEFAULT category, the BROWSABLE category is might be causing the problem.
Add a .*.ics path pattern to capture any files that have been given the wrong mime type by the server
Put all the data matching into the same filter
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.splitbrain.giraffe"
android:versionName="0.31" android:versionCode="4">
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name" android:theme="#android:style/Theme.Light.NoTitleBar">
<activity android:label="#string/app_name" android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/calendar" />
<data android:scheme="webcal" />
<data android:pathPattern=".*.ics" />
</intent-filter>
</activity>
<activity android:name="OptionsActivity"></activity>
<activity android:name="DetailActivity"></activity>
<activity android:name="AboutActivity"></activity>
</application>
</manifest>

Categories

Resources