Google plus integration in WebView
Posted By : Sapna Sharma | 04-Mar-2015
Before you can begin integrating your app with the Google+ components, you must create a Google Developers Console project.
Creating Google Developers Console project
To enable the Google+ API for your app, you need to create a Google Developers Console project, enable the Google+ API then create a client ID.
- Go to the Google Developers Console.
- Select a project, or create a new one.
- In the sidebar on the left, select APIs & auth .
- In the displayed list of APIs, make sure the Google+ API status is set to ON, as well as any other APIs that your app requires. If you plan to use other APIs, turn those on as well.
- In the sidebar on the left, select Consent screen.
- On Consent screen choose your Email and fill your Product Name
- Click the Save button.
- In the sidebar on the left, select Credentials.
- In the OAuth section of the page, select Create New Client ID.
In the resulting Create Client ID dialog box, do the following:
- Select the installed application type.
- Fill the remaining on the basis of installed application type selected
- Click the Create client ID button.
Following is the code to integrate Goolge+ in WebView . Replace client_id in url with your app’s client ID
var win = Ti.UI.createWindow({
barColor : '#000',
navBarHidden : true
});
var textToShare = encodeURIComponent('This text will be shared');
var urlToShare = encodeURIComponent('http://www.oodlestechnologies.com');
var webView = Ti.UI.createWebView({
scalesPageToFit : true,
touchEnabled : true,
url : 'https://plus.google.com/share?client_id=921567304267-0movad07mqcpvqitba5obk5339257oq6.apps.googleusercontent.com&continue=' + Ti.App.id + '%3A%2F%2Fshare%2F&text=' + textToShare + '&url=' + urlToShare + '&bundle_id=' + Ti.App.id + '&gpsdk=1.0.0'
});
win.add(webView);
win.open({
modal : true
});
webView.addEventListener('error', function(e) {
win.close();
});
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Sapna Sharma
Sapna is a bright Android Apps developer using Titanium framework. Sapna likes music and helping needy people.