How to open website in webview as user signed in chrome? - google-chrome

I'm going to open google hangouts site in webview of my chrome packaged app as user signed in chrome.
I can get auth token that way:
chrome.identity.getAuthToken({ 'interactive': true }, function(token) {
console.log(token);
});
but in webview I can see sign in page instead of hangouts site. It seems that webview doesn't have access to auth token.
Here is code displaying webview:
<webview id="id1" partition="persist:googlepluswidgets" src="http://g.co/hangout" style="width:100%;height:100%;"></webview>
Any ideas to share auth token with webview and open site directly, without log in?
Is it at all possible to do it using auth token? If not, is there another method to authorize user while opening that site in webview?

Related

Redirection from html page to itunes in InAppBrowser in ios cordova

We are not able to redirect from one html page to itunes from InAppBrowser in ios cordova.
We are using following logic for redirection from html page to itunes :
1) window.open("itunes url","_system");
2) window.open("itunes url","_blank");
3) window.location = "itunes url";
We are able to navigate to play store in android using window.location.
Please suggest appropriate solution for this issue.
PS : The itunes url is having location of our app on app store.

How to open other app installed on IOS from HTML run in Safari

Is there a way to open any app installed on Iphone/Ipad? is there a way to open that app from HTML run in Safari.
Please help me. Thank you very much!
Yes, but only if you know the apps URL scheme.
Like for example, Facebook App registers the app URL fb:// so if you create a herf you can open the Facebook app:
Launch Facebook app
Yes you can, If you know the URL scheme of that app.
For eg. URL scheme of whatsapp is whatsapp:// so you can open whatsapp from safari by typing whatsapp:// in your browser.
You can also set URL scheme to your app so that any one can open your app from browser by entering URL.
Check this great tutorial If you want to create a custom URL scheme for your app.

Launch Chrome app using extension

I have a standalone frame-less Chrome app. I'm sending messages from another Chrome extension to it (Chrome app) which works. But I would like to be able (if it's possible) to launch the app using the extension. Because now I have to launch the app manually.
I've seen Google music "mini player" that you can launch from music.google.com. So I'm wondering if the same can be done using chrome extension.
I wouldn't need the Chrome extension if the Chrome app could read opened tabs or just URLs but since this is not possible one must use extension and message to app to achieve this.
just send msg to your app from extension when you want to open it (In my case, I'm opening app when injected element on page is clicked)
extension script:
var appID = "qwertzuiopasdghghjkhgjghj";
element.onclick = function () {
chrome.runtime.sendMessage(appID, {message: 'fireup'}, function(response){});
});
app background script:
chrome.runtime.onMessageExternal.addListener(function(request, sender, sendResponse) {
if (request.message == 'fireup') {
chrome.app.window.create("page.html",
{
//whatever
});
}
});
You can use chrome.management.launchApp method: https://developer.chrome.com/extensions/management#method-launchApp
To use it you need to add "management" permission to your extension manifest file

URL to open iOS app in App Store web page and iTunes app simultaneously

What is the preferred URL to use to open an iOS app in it's App Store web page as well as the iTunes app (when available on the host device)?
I've tried using the itms:// protocol but this opens the app details in the iTunes app only and so is of no use when the URL is navigated to from an Android or Windows phone for example.
I believe you would want to look at the browser to determine which link to use. If the browser is Safari on iOS device, give them the iTunes protocol link, otherwise, http://.
I believe javascript allows you to read such information: Take a look here: http://www.w3schools.com/js/js_browser.asp
I've discovered that the behaviour of a URL opening an iTunes preview web page before automatically opening the iTunes app on the host device (where available) is triggered by affiliate links (which need to track the click before taking the user to the intended destination).

Obtain cookies of the page being visited

I want to know how can we obtain the cookies of the current page being accessed using a communication link between the content script and background page. This is for an extension.
You can use Content Scripts to access document.cookie for each website you visit. Then you can use Message Passing to pass the cookies from your Content Script to your Background Page.
There are many examples on Stack Overflow for example:
Chrome Extension: how to capture selected text and send to a web service
Chrome Extension: How to pass a variable from Content Script to background.html
Google Chrome Extension - Architecture Question
Chrome extension: accessing localStorage in content script
In background.html,how can I access current web page to get dom
Help with chrome extension message passing