Send/Receive Data between Native Android and Phonegap App - android

I want to exchange data between a native android application and a phonegap application, how is this possible?
I've been reading the developers' guide: https://developer.android.com/training/sharing/index.html and I'm wondering if this is supported to a phonegap/cordova application and how (e.g. via a cordova-plugin)
I have been searching for some cordova-plugin buy I have only found out the cordova-plugin-customurlscheme which partially does what I need for my use case
Simply put, what I need is to do some processing of some data and send them to another android application installed to the same device and vice versa.

Based on the tutorial you provided, it seems that an intent with a given action (for example ACTION_SEND) and a given mime type (for example text/plain) can only share data with applications which have the same action and mime type (in our example, ACTION_SEND and text/plain).
So from a quick Google search, I discovered the following plugin which seemignly allows you to set a mime type and an action for Cordova applications when running on the Android platform. (I have not tried it myself).
https://github.com/napolitano/cordova-plugin-intent
I hope this helps!

Related

In mobile, can different apps respond to a browser call-to-action and open directly?

I'd like to design a cross platform protocol that any app on mobile or app on your desktop can respond to.
On desktop the best example is torrents, where you have a magnet link of the form magnet:?urn:btih:abcabcabcabcabcabcabcabc etc. that can be opened by any app that supports the magnet: scheme. There also exists .torrent files which can be opened by anything that supports .torrents (although this won't open directly).
Is something like this possible on mobile? From my initial research it appears that iOS doesn't let multiple apps register the same uri scheme so customuniversalscheme:// won't work. I also vaguely recall mobile safari opening files in browser and not in separate apps or even being able to download the files, but i'm not sure about that anymore...
What about android? Can multiple apps respond to the same custom scheme? Files can be downloaded on android, but can files be opened directly in browser?
Is the user flow I am thinking about possible on mobile? If so, how? If not, what's the next best alternative?
So I think your comparison with the desktop torrent flow is a bit wrong. On desktop you can choose the default app to open a file or you can "Open With" an app that you want, on mobile it's a little bit different and more complicated.
So mainly on mobile platforms you open an app with a deep-link and iOS has two ways of deep-links:
the old and well known URL scheme that you defined above
the universal-link, this one is used a lot (iOS 9 and above) to forward a link, that usually will be opened in browser, to the app that responds to the universal link (it's very similar to the URL scheme thinghy)
For Android you have something similar using intent-filters and as far as I know it's possible to have multiple apps that respond to the same deep-link, but if I remember correctly the user will be prompted with an app picker (to select which app to use).
Now this is a short summary about deep-links, but from my experience the main issue with deep-links is now how you create them, it's about the app that must "forward" them. For example, on Android there are so many web browsers (not chrome) that won't forward the deep-link to the system in order to check if there is an app that can open them.
Now, if you can pass this problem, what I think you could do to unify the implementation for both platforms is to link your framework/lib/app to an API that will generate a unique deep-link scheme for every app. For example I want to "respond" to your deep-links so I register my app on your platform, with the bundle id and package name (which are unique), and your system will generate a unique combo of package name / bunde id and other number. When your lib/app/framework launch you will fetch all the configured bundles and try to fire a deep-link for each of them, this approach is kind of limited by the number of registered apps.

How to launch an app from a SMS message in Android and iOS, along with encrypted data for the apps to use

I'm developing an app for iOS and Android that i want users to be able to launch when they receive a SMS message that contains a link.
The link includes the app package as well as encrypted data in the following format:
"com.app.myapp://?<encrypted data>" (the <> brackets are not included and the encrypted data is never over 120 characters)
On iOS, this works perfectly as the SMS link comes in correctly hyperlinked to include all of the encrypted data, the app launches and all is well.
Android on the other hand, the link comes in broken...only the "com.app.myapp" is hyperlinked, which still launches the app when clicked, but it does not pass the encrypted data. So it seems like Android is breaking the link.
One fix i had for android was to add "http://" to the beginning of the link, this kept the hyperlink fully intact in Android, but on iOS the link with http would no longer launch the app.
Also removing the ':' after the package name fixed it for Android, but again broke the iOS functionality.
I know its not an app issue, its more a Android Messages issue / possibly a link formatting issue.
Is there another solution i can try?
You cannot add http:// in front of com.app.myapp:// because they are both uri schemes. You should familiarize yourself with the difference between URI Schemes and App Links. Since you are using URI schemes to accomplish this, you should not be using .. Your URI scheme should look something like myapp:// not com.app.myapp://. This is probably why Android Messenger is ignoring everything after the ://.
An easier solution would be to use Branch SDK and pass along the encrypted data in the link data.
EDIT
Android messenger does not recognize raw URI schemes as clickable links. You probably still need to use http for android. You should look into using Android app links and iOS universal links. These take a bit more set up but should handle links in both cases

Manually open hyperlinks in specific app in Android

I use the Twitter app to follow a lot of news outlets. Each one of them posts links to articles on their websites. I want to open those articles in the news outlet's dedicated Android app. Some of them, like the NYTimes app, does it by itself. But most of them don't. I'm figuring that's because they haven't declared an intent in their app to do so. So basically I want to write an app that would give me an option to redirect the hyperlink of the article to a specific app, and I want to do it for multiple apps. Would it be possible to create a regex that would run on the URL and redirect it to the proper app accordingly?
Would it be possible to create a regex that would run on the URL
That is impossible to state in the abstract. Android's <intent-filter> system does not allow for filtering on all parts of a URL.
and redirect it to the proper app accordingly?
That is impossible to state in the abstract:
There is no requirement for the app for a news site to have any means for outside apps to tell it what to view
There is no requirement for an app's developers to document how to convert a Web site URL to whatever input would be available to tell the app to go view something
So, what you want may be possible for some news apps, but the details would vary by app.
Not that I am aware of - though this is an interesting concept.
Here are some things to know:
the twitter app doesn't care how the intent is resolved. the purpose of the intent is to share external data. once the twitter app has handed over the intent with the url it is up to the android system to decide which app can resolve.
the NY Times app is capable of opening because of this feature: https://developer.android.com/training/app-indexing/deep-linking.html
Workaround:
Learn to develop your own Android ROM to modify the Android Open Source Project adding your logic for intent resolution, compile and get your new Android ROM ready for deploy, install ROM on phone, keep your fingers crossed the entire time.

Url schema for Whatapp in android

I want to launch whatsapp from my hybrid application using phonegap. I went through the whatsapp url schemas.It is working fine with iOS . Here is the schema is used for iOS:
href = "whatsapp://send?abid=123&text=hello"
reference from :
http://www.whatsapp.com/faq/en/iphone/23559013
As described abid is address book id. If I give correct abid the application redirect to the particular contact.
But as per my reading abid is not possible in android . Currently I am using url with out abid which redirects the application to the recent chats. so is there any way to redirect the application to the particular contact ?
For Android, use Webintent plugin
EDIT
See whatsapp phonegap plugin.
iOS supports a generic URL scheme for whatsapp ("whatsapp://send?abid=").
However on Android the URL scheme is currently not supported.
This plugin implements the send-via-whatsapp functionality on Android.
Two recent solutions (July 2017)
There's been many changes in that need lately but finally after years I've found, tested and refered two new different solutions that should work with any device (one is official). I've mentioned them in THIS OTHER ANSWER (because S.O. policies I had to put a link to the solution, no duplicates).

mobile web - Opening native mapping application with anchor's href?

I've been developing an application for the Business for which I work, and thus far, I have succeeded in making each page mobile/desktop compliant using a combination of media queries and IE conditional comments, but the "locations" page has me stumped.
I want the address of each location to serve as a link which will be treated the way different MIME types are treated. Android seems to have this functionality covered with "intents" IE
geo:0,0?address
This also works on my N9, though from my testing using the iOS simulator, that can't open a "geo:" link. Is there a cross-browser way to create this functionality?
Thanks!

Categories

Resources