At first please do not mar this question as duplicate. All other questions are old and I've tried solutions from most of them and none of them work.
I'm working on an Android app and I'd added my app to share Android menu. I'd like to add functionality so if user clicks my app on the share list e.g. in Chrome browser or Google Drive app, my app will receive the data from that app e.g. from Chrome it wold be URL.
I've tried to use different plugins and read many posts about how to use intent in my app. Unfortunately none of them work.
I've tried:
Sending url to ionic android app via webintents from another app - this one looked very promising
https://www.npmjs.com/package/phonegap-webintent
https://github.com/napolitano/cordova-plugin-intent - this one looked promising as well
https://github.com/okwei2000/webintent
https://github.com/stample/cordova-sharingreceptor
Did anyone got this working?
My AndroidManifest.xml is as follows - the part about intent:
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="*/*" />
</intent-filter>
In my config.xml I have:
<preference name="AndroidLaunchMode" value="singleTask" />
And I'm not getting data I'm expecting.
When I'm using https://github.com/napolitano/cordova-plugin-intent plugin I'm getting the intent but clipItems element is missing and the plugin is useless.
What am I doing wrong?
Any help appreciated.
Finally I've done it.
I used https://github.com/napolitano/cordova-plugin-intent ver 0.1.3 and
window.plugins.intent.setNewIntentHandler(function (intent) {
// To get browser URL I had to use
var subject = intent.extras['android.intent.extra.SUBJECT'];
var url = intent.extras['android.intent.extra.TEXT'];
// For Chrome, Opera and FireFox it works. For build in Android browser TEXT holds page title and URL joined with +
});
Although ver 0.1.3 has
window.plugins.intent.getRealPathFromContentUrl(contentUrl, function (realPath) {}, function () {});
available I couldn't use it because this didn't give me the data I wanted. contentUrl is different for differen browsers e.g. for Chrome it is uri and for build in Android browser it's text.
I installed ver 0.1.3 using CLI
phonegap plugin add https://github.com/napolitano/cordova-plugin-intent.git#61a47ae8c28a62004eeff4ed96a6f3c64c271a16
I couldn't add it using tag in config.xml
I hope this will help others.
Related
I am trying to save a deep link in my calendar and make it clickable.
My URI has a format like
appname://timer?2000sec&ringtone?jinglebells.
On iOS, in the Calendar, I see it properly. It shows the text in red and if I click it, it opens the app. This, btw, is under "notes", not in the URL field.
On Android however this does not seem to be working properly, the Deep Link is not recognized. It works in other places! I know if the info.plist has a wrong name for the scheme it won't recognize, but I created an HTML page with the appname:// as hyperlink, and if I open it in chrome and click it, it does exactly what it is supposed to, so the AndroidManifest.xml should be set up correctly. But unless I specifically mark it as a Link (be it hyperlink or anything else) it is seen by Android as plane text.
Now, is there a way to force Android to see it as something clickable in the notes field in the Calendar?
Side info:
<!-- Deep linking, this is under the mainActivity <activity> tag -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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="rheinbahnnextgen" />
I am using flutter for this, the package I am using is https://pub.dev/packages/add_2_calendar
As I just found out, Google Calendar supports hyperlinks
link
I am a developer of a basic e-commerce app which has a companion website. I wanted to try app links as a way to direct my users from my website to certain screens on my mobile app.
The applinks website tutorial gives the following example as a way to introduce app links to a certain app.
This is possible if I wanted to "link" to just one screen in each app. But what do I have to do if I want to link to multiple screens?
I want the website to be able to direct the user to the home screen, the search screen as well as the payment screen. Is there an efficient way to do this? Do I have to add different app links on different pages?
EDIT
Thanks for the response Alex. I've tried to follow your guide for my Android app but it doesn't seem to work. Whenever I open the URL of my website on the Android Chrome browser nothing happens. I want an automatic redirect to my app.
This is a snippet of my code (under pseudonyms for the names and urls).
Website:
<meta property="al:android:url" content="ecommerceapp://dlogsman" />
<meta property="al:android:app_name" content="ECommerceApp" />
<meta property="al:android:package" content="com.ecommerce.app" />
<meta property="al:web:url" content="http://ecommerce.com/~dlogsman" />
Android Manifest:
<activity
android:name="com.ecommerce.app.App"
android:label="#string/app_name_ecommerce">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:scheme="ecommerceapp" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
And then my onStart method handles the intent exactly like you recommended. Any suggestions?? Thanks again for the time.
As a heads up, I work on the Branch linking tool (branch.io) which helps simplify deep linking across all channels including Facebook (and simplifying the AppLinks nightmare)
What App Links do is simply tell the Facebook robot how to map a corresponding website URL to your native app URL. It's just a set of metatags to add to your site's header in order to tell Facebook which app URL to call when the app is installed. The only actual link is your website link. Therefore, you can only have 1 set of AppLinks on a given page on your existing ecommerce site. In order to use AppLinks to different pages in your app, you'll need to actually have different web URLs. So, you'll need to have a:
http://yourecommercesite.com/home and add metatags for yourecommerceapp://home
http://yourecommercesite.com/search and add metatags for yourecommerceapp://search
http://yourecommercesite.com/payment and add metatags for yourecommerceapp://payment
Then, you'll need to structure your app for deep linking. In case you haven't done that, here's how to set it up and receive the URL path in iOS:
Add the URI scheme for yourecommerceapp:// to the PLIST file
Write the code to receive the URI path
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([[url path] hasSuffix:#"home"]) {
// load the home view controller
} else if ([[url path] hasSuffix:#"search"]) {
// load the search view controller
} else if ([[url path] hasSuffix:#"payment"]) {
// load the payment view controller
}
return YES;
}
And here's how in Android:
Setup the app Manifest to receive intents from yourecommercesite://. You just need to add this inside the <activity></activity> tags
<intent-filter>
<data android:scheme="yourecommercesite"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
In onStart of the Activity that receives the intent, add the following code:
#Override
protected void onStart() {
super.onStart();
if (this.getIntent().getData() != null) {
if (this.getIntent().getData().getPath().equals("home")) {
// load the home activity
} else if (this.getIntent().getData().getPath().equals("search")) {
// load the search activity
} else if (this.getIntent().getData().getPath().equals("payment")) {
// load the payment activity
}
}
}
We are trying to implement Google's App Indexing feature. We've added the deep links to our website with the rel-alternate tag in the following format:
android-app://id.of.the.app/scheme/?screen=Product&product=123456
Now we get content mismatch crawling errors. If I use the QR code for testing from here everything works fine. But if I open a crawling error, click on "Open App Page" and use the adb command for testing I can see that everything starting from the ampersand doesn't get passed to the app and therefore my product data cannot be loaded. I suspect that's how the crawler checks the content of the app and that's why we get Content Mismatch Errors.
Also if I use the "Fetch as Google" from the Search Console it looks like everything from the ampersand gets cut off.
I checked on eBay as it is working with their app and that's the link they are using:
android-app://com.ebay.mobile/ebay/link/?nav=item.view&id=221559043026&referrer=http%3A%2F%2Frover.ebay.com%2Froverns%2F1%2F711-13271-9788-0%3Fmpcl%3Dhttp%253A%252F%252Fwww.ebay.com%252Fitm%252FRoxy-Fairness-Backpack-Womens-Red-RPM6-%252F221559043026%253Fpt%253DLH_DefaultDomain_0
They have encoded the ampersand with & but if I do that and test it with the "Fetch as Google" function it doesn't work either.
These users seem to have the same issue, but they didn't share a solution (if they found one):
https://productforums.google.com/forum/#!msg/webmasters/5r7KdetlECY/enYknTVkYU4J
https://productforums.google.com/forum/#!topic/webmasters/lswyXKlS-Ik
I'm thankful for any ideas.
Update 1
That's how I'm interpreting the deep link inside the Android app:
Uri data = getIntent().getData();
String scheme = data.getScheme();
if (scheme.equals("scheme")) {
String screen = data.getQueryParameter("screen");
if (screen.equals("Product")) {
String product = data.getQueryParameter("product");
// Open Product and give it product number as intent data
}
}
Update 2
Here's the relevant part of our Manifest.xml:
<activity
android:name="id.of.the.app.StartActivity"
android:configChanges="orientation|screenSize"
android:label="#string/app_title"
android:windowSoftInputMode="adjustPan|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="scheme" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Update 3
I'm still trying to understand if it's is possible to avoid a change to the manifest and resubmit the app. With the AndroidManifest you have published, have you tried to change just the rel-alternate tag to include a host (event if it's not included inside the manifest)? For example have you tried with android-app://id.of.the.app/scheme/fakehost/?screen=Product&product=123456 where fakehost is a string? I guess that the syntax of the tag must be android-app://{package_name}/{scheme}/{host_path}so it's neccessary to have an host in the web site (but probably not on the app).
Update 2
After you published the Manifest, I guess you're missing the mandatory 'host' in the data tag of your Intent-Filter.
Get this as reference:
<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="link"/>
<data android:scheme="myapp" android:host="link/"/>
</intent-filter>
and the meta in html should be (android-app://package-name/scheme/host)
<html>
<head>
<link rel="alternate"
href="android-app://it.test.testdeeplink/myapp/link/?p1=1&p2=2" />
...
</head>
You probably need to update your app, since your Manifest will have to be fixed.
First, thanks for all clarifications. I guess there is some confusion about deep link (the feature you're implementing) and Chrome Intent (the link that you provided as comment). So, I decided to implement a small project that you can download by my dropbox folder. The project is very simple and has a single activity that prints a line for every parameter received by Intent data (of course if you launch the app by the app launcher you won't see anything). The Activity supports two intent-filter schemas (my-android-app and http), and at the end of MainActivity.java you can find (as comment)
A line to test deep linking against adb and the first schema
A line to test deep linking against adb and the second schema
A simple html page to test the deep link using a browser - the last two href are Intent properly managed by Chrome.
Since I don't have access to your code, and I cannot see if there is any issue, I guess this is the best way to help you and to get my answer accepted :)
App indexing with query params in the Uri works fine for me. Please check if you followed all steps correctly:
Declare the scheme for the id.of.the.app.StartActivity in the AndroidManifest.xml
<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="my_custom_scheme"/>
</intent-filter>
Parse deeplink
Let's assume we have following deeplink my_custom_scheme://test_authority/product_screen/?product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing
public void parseDeeplikUrl(Uri uri) {
if (uri == null) {
// fallback: open home screen
}
String autority = uri.getAuthority();
String path = uri.getPath();
String query = uri.getQuery();
// authority = "test_authority"
// path = "products_screen"
// query = "product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing"
}
Test app indexing from command line:
adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "my_custom_scheme://test_authority/product_screen/?product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing" -e android.intent.extra.REFERRER_NAME android-app://com.google.appcrawler/https/www.google.com id.of.the.app'
Using this adb command we simulate GoogleBot call.
Go to "Fetch as Google" in Search console and check if GoogleBot works fine too and renders correct application screen.
android-app://id.of.the.app/my_custom_scheme/test_authority/product_screen/?product=123456&test_param=0000&utm_source=google&utm_medium=organic&utm_campaign=appindexing
P.S.: Sometimes GoogleBot isn't rendering screens correctly. I got few empty screens with correct the deeplinks. In that case try to execute the same deeplinks again. It worked for me.
I actually want to capture the weblink which can trigger my app to launch.
I am using the code as given below. [written in AndroidManifest.xml].
<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:host="mysite.com"
android:pathPrefix="/_mobile/"
android:scheme="http"
/>
</intent-filter>
Launching of an app is a success when I try to visit "mysite.com/_mobile". Basically, the aforementioned link is actually a link to the mobile version of my main website. Now, if a user has the app installed, it should open the app rather than the mobile web page. So far, it works great. Now the problem is when I want to navigate to a specific page in an app. for example, "mysite.com/_mobile?productId=103" - this would open a page for productId=103 in mobile web view. But, incase the user has my app installed, how can I redirect him to this productId page in an app.
I did some googling on this topic and stumbled upon a cordova plugin. I added this plugin, so called "Initsogar/cordova-webintent" here. Now, I am using this code,
window.plugins.webintent.getUri(function(url) {
if(url !== "") {
alert("URL was "+url);
}
});
All I want is to get the uri which launched the app. I do not get the desired outcome. I tried to alert some value to check if this code is working or not, it seems its NOT.
see the code that i used for testing:
window.plugins.webintent.getUri(function(url) {
alert(2);
if(url !== "") {
alert("URL was "+url);
}
});
Here, 2 is not alerted. I dont know whats wrong with this plugin. other than this, I have no clue where to start from. any help would be great. :)
Having spent two days banging my head against my desk, I've decided to ask for some help...
I'm trying to share videos and other links to my air for android app that I am developing with Flash CS6. I have added to following to my manifest file:
<![CDATA[
<manifest>
<application>
<activity android:name=".ui.MyActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
I know that this is supposed to trigger the activity ".ui.MyActivity" when the SEND intent is invoked. I have also added the following code to my AS code:
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onAppInvoke);
function onAppInvoke(event:InvokeEvent):void {
Status_txt.text = event.arguments.toString()
Status_txt.text += event
}
But i really haven't had much luck. The best result i've obtained is the opening of my app but the event.arguments array is empty. Other results include the foce closing of my app whenever other share with it or the failing of my app to compile.
Does anyone have any advice?
Thanks in advance!
Smollett