Prevent tweet URLs from being opened by native Twitter app on Android - javascript

I'm working on an app built in Titanium that has a few "Tweet about this" buttons. Since I can't use the Javascript part of a Tweet button as described in Twitter API, I just use a plain URL with parameters.
On Android, this causes problems. When users click this link, they get a choice how to open it: always the native browser, and additionally any app that has registered for this kind of link. So if the user has the Twitter app installed, Twitter will be shown as one of the options.
That would be great, except the Twitter app is awful. Most types of suggest-a-tweet URL cause the app to crash, and the few that do work don't pass the status text.
I'm looking for a way to force the URL to be opened by the native browser. (Or way to prevent the Twitter app from being among the options presented to the user, but that seems harder to do)
Is this possible using only the URL itself, or maybe a little Javascript? Since I'm using Titanium, Java won't help me.

I can't give you what you want but give you an alternative suggestion.
What you are trying is hard (often impossible to do without errors) even with native code as your trying to work against the OS. Intents are used in android as a way to let the user decide which program should handle a certain request. If you don't want the user to take this decision I'd suggest opening the url in a embedded browser.

Related

Swift Deep link check if app is installed

I just stumbled upon the concept of deep links, allowing people to send data to the app using specific URL's. I looked into this, and I have now successfully managed to implement it in my app. However, I have one question. I was wondering if it was possible to detect if the app was installed or not, while clicking the specific link in for example Notes or on Safari - and if not - take the person to the App Store.
Is this possible?
Thanks in advance.
Yes, this is possible. However it requires some workarounds, because you can't actually detect if an app is installed in situations like this. Apple and Google have limited that for obvious privacy reasons.
The basic flow is this:
Attempt to open the app via a deep link (Universal Links in most situations, or a custom URI scheme redirect wrapped inside a regular HTTP/HTTPS link in rare cases)
If this attempt fails, use your fallback URL (the actual URL of a Universal Link, or the page where you wrapped your custom URI scheme redirect) to then forward the user to the App Store to download.
The real magic happens when you are able to do deferred deep linking. This means storing the value of the deep link remotely so you can send the user to the right place in your app, even when the app is not installed yet.
This is exactly how Branch.io (full disclosure: I'm on the Branch team) works. You can find a much better overview of the process on this page.

Developing a browser extension for Chrome and Firefox to hook into Button events

I know this is quite broad question but I want to ask about developing a browser extension for Chrome and Firefox, specifically if this is something that can be done without rocket science. The core concept of what I need to do is to have a way to hook into specific button when on a specific page that it will prevent its default behavior first, instead show a Form Modal which loads a URL from third-part (external) site possibly (iframe) or something. Then the Form Modal have this function to validate if reference number or license number is valid before allowing the actual button (in the main page) to be clickable.
The case here is that the web app is already done (a SaaS), and it is almost impossible to extend through API so we will need to hook into it and inject the project the is described above.
This may look like a malicious extension but basically it will be used not for that but for a eCommerce site as third-party integration.

Using fb:// To Share a Post through the Facebook App with Web Interface

One of my sites has a custom share plugin that I've written and I would like to try to get the 'sharing' feature to open up in the native Facebook app if possible. I know that you can use fb:// to open up the app but from what I've read, this is part of FBML which has been deprecated for several years. What I ideally would like is to have the link open up the FB app with a pre-populated link in the share box that the user could then just automatically share. Basically the functionality of the sharer.php script (it's ok if it pulls the data from the OG tags).
I know it can be done in iOS apps (and probably Android) but is it possible to do through a web interface?
I have the links I'm using only showing on mobile devices through some Javascript so I wouldn't have to worry about it causing any problems sitewide.
Thanks for your help!
var url = encodeURIComponent('http://example.org/');
window.open(
'https://www.facebook.com/sharer/sharer.php?u='+url,
'Share on Facebook',
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600'
);
That's the simplest way I do it ;)

Facebook Login and UIWebview

I'm currently developing an app that is essentially a single WebView that allows access to a specific website (terrible idea I know, but the decision comes from higher up); said website offers the option to login through Facebook with the standard Facebook Connect procedure.
The login process works fine in Mobile Safari but unfortunately when a UIWebView attempts to do the same thing after authorizing a blank page is displayed and nothing happens. This is of course because of the page actually being just a JavaScript that communicates with the original page through postMessage (I think!).
I tried searching and while this is a pretty widely recognized problem all the solutions I found are either not applicable or won't work. I found somewhere that it's possible to pass mode=redirect to the oauth URL to prevent the whole process to involve popups which sounds promising but as far as I tell it doesn't work.
Is there a way to make Facebook Connect work for a website inside a UIWebView? I'm considering the option of having the Facebook button call a special URL that I would then listen to inside the ap to trigger a native authentication process but unfortunately since my company is not the one developing the website so this kind of solution would be the least preferred.

Deep linking javascript powered websites

I have a website which has two versions, an all singing all dancing javascript powered application which is served when you request the root url
/
As you navigate around the lovely website the content updates, as does the url, thanks to html5 push state or good old correctly formatted #! urls. However if you don't have javascript enabled you can still use all functionality of the site as each piece of content also exists under it's own url. This is great for 3 reasons
non javascript users can still use the site
SEO - web crawlers can index the site easily
everything is shareable on social networks
The third reason is very important to me as every piece of content must be individually shareable on the site. And because each piece of content has it's own url it is easy to deep link to that url, and each piece of content can have it's own specific open graph data.
However the issue I hit is the following. You are a normal person and have javascript enabled and you are browsing and image gallery on the site and decide to share the picture of a lovely cat you have found. Using javascript the url has been updated to
/gallery/lovely-cat
You share this url and your friend clicks on it. When they click on the link the server sends you the non javascript / web crawler version of the site, and the experience is no where near as nice as the javascript version you would have been served if you directly went to the root of the site and navigated there.
Do anyone have a nice solution / alternative setup to solve this problems? I have several hacks which work, however I am not that happy with them. They include :
javascript redirect to the root of the site on every page and store a cookie / add a #! to the url so on page render the javascript router will show the correct content. ( does google punish automatic javascript redirects? )
render the no javascript page, and add some javascript which redirects the user to the root, similar to above, whenever the user clicks on a link
I don't particularly like either of these solutions, but can't think of a better solution. Rendering the entire javascript app for each page doesn't appear to be a solution to me, as you would end up with bad looking urls such as /gallery/lovely-cat/gallery/another-lovely-cat as you start navigating through the site.
My solution must support old browsers which do not implement push state
Make the "non javascript / web crawler version of the site" the same as the JavaScript version. Just build HTML on the server instead of DOM on the client.
Rendering the entire javascript app for each page doesn't appear to be a solution to me,
That is the robust approach
as you would end up with bad looking urls such as /gallery/lovely-cat/gallery/another-lovely-cat
Only if you linked (and pushStateed) to gallery/another-lovely-cat instead of /gallery/another-lovely-cat. (Note the / at the front).
Try out this plugin it might solve your 3rd reason, along with two reasons.
http://www.asual.com/jquery/address/

Categories