{"_id":"5759a5475577ba2b00cc430a","version":{"_id":"5759a5475577ba2b00cc4306","project":"575656e0a71a711700de7eef","__v":1,"createdAt":"2016-06-09T17:20:07.619Z","releaseDate":"2016-06-09T17:20:07.619Z","categories":["5759a5475577ba2b00cc4307","5759a5475577ba2b00cc4308","5759a5475577ba2b00cc4309"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.3.1","version":"1.3.1"},"__v":0,"category":{"_id":"5759a5475577ba2b00cc4307","version":"5759a5475577ba2b00cc4306","project":"575656e0a71a711700de7eef","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-07T05:08:48.222Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"project":"575656e0a71a711700de7eef","githubsync":"","parentDoc":null,"user":"57429d54990c970e00386e12","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-07T05:08:48.254Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"## Installation\n\nRun\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"tns plugin add nativescript-social-login\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\ninside your app project to install the module.\n\n### Android\n\n#### AndroidManifest.xml\n\n##### Permissions\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<manifest xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\">\\n    <!-- ... -->\\n\\n    <uses-permission android:name=\\\"android.permission.READ_EXTERNAL_STORAGE\\\" />\\n    <uses-permission android:name=\\\"android.permission.WRITE_EXTERNAL_STORAGE\\\" />\\n    <uses-permission android:name=\\\"android.permission.INTERNET\\\" />\\n    <uses-permission android:name=\\\"android.permission.ACCESS_NETWORK_STATE\\\" />\\n\\n    <!-- ... -->\\n</manifest>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n##### Activities\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<manifest xmlns:android=\\\"http://schemas.android.com/apk/res/android\\\">\\n    <!-- ... -->\\n\\n    <application>\\n        <!-- ... -->\\n\\n        <meta-data android:name=\\\"com.facebook.sdk.ApplicationId\\\" android:value=\\\":::at:::string/facebook_app_id\\\" />\\n\\n        <activity android:name=\\\"com.facebook.FacebookActivity\\\"\\n                  android:configChanges=\\\"keyboard|keyboardHidden|screenLayout|screenSize|orientation\\\"\\n                  android:theme=\\\"@android:style/Theme.Translucent.NoTitleBar\\\"\\n                  android:label=\\\"@string/app_name\\\" />\\n\\n        <!-- ... -->\\n    </application>\\n\\n    <!-- ... -->\\n</manifest>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n##### Strings\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n<resources>\\n    <string name=\\\"facebook_app_id\\\">YOUR_FACEBOOK_APP_ID</string>\\n</resources>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n#### app.gradle\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"buildscript {\\n    repositories {\\n        jcenter()\\n        mavenLocal()\\n    }\\n    dependencies {\\n        classpath 'com.android.tools.build:gradle:2.1.0'\\n        classpath 'com.google.gms:google-services:3.0.0'\\n    }\\n}\\n\\nrepositories {\\n    mavenCentral()\\n    maven { url 'https://maven.fabric.io/public' }\\n}\\n\\ndependencies {\\n    compile 'com.facebook.android:facebook-android-sdk:4.6.0'\\n    compile 'com.google.android.gms:play-services-auth:8.4.0'\\n\\n    compile('com.twitter.sdk.android:twitter:1.13.2@aar') {\\n        transitive = true\\n    }\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n## Usage\n\n### Include\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import SocialLogin = require(\\\"nativescript-social-login\\\");\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n### Initialize\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import Application = require(\\\"application\\\");\\nimport SocialLogin = require(\\\"nativescript-social-login\\\");\\n\\nif (Application.android) {\\n    Application.android.onActivityCreated = (activity) => {\\n        var result = SocialLogin.init({\\n            activity: activity\\n        });\\n    });\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n### Login\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SocialLogin.loginWithFacebook(\\n    (result) => {\\n        console.log(\\\"code: \\\" + result.code);\\n        console.log(\\\"error: \\\" + result.error);\\n        console.log(\\\"id: \\\" + result.id);\\n        console.log(\\\"userToken: \\\" + result.userToken);\\n        console.log(\\\"displayName: \\\" + result.displayName);\\n        console.log(\\\"photo: \\\" + result.photo);\\n        console.log(\\\"authToken: \\\" + result.authToken);\\n    }\\n);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n#### Supported functions\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Function\",\n    \"h-1\": \"Provider\",\n    \"0-0\": \"loginWithFacebook\",\n    \"1-0\": \"loginWithGoogle\",\n    \"1-1\": \"Google\",\n    \"0-1\": \"Facebook\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n## Logging\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SocialLogin.addLogger(function(msg, tag) {\\n    console.log('[nativescript-social-login]: (' + tag + '): ' + msg);\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"Quick start guide","slug":"getting-started","type":"basic","title":"Getting Started"}

Getting Started

Quick start guide

## Installation Run [block:code] { "codes": [ { "code": "tns plugin add nativescript-social-login", "language": "shell" } ] } [/block] inside your app project to install the module. ### Android #### AndroidManifest.xml ##### Permissions [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <!-- ... -->\n\n <uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />\n <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n <uses-permission android:name=\"android.permission.INTERNET\" />\n <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />\n\n <!-- ... -->\n</manifest>", "language": "xml" } ] } [/block] [block:code] { "codes": [ { "code": "", "language": "text" } ] } [/block] ##### Activities [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <!-- ... -->\n\n <application>\n <!-- ... -->\n\n <meta-data android:name=\"com.facebook.sdk.ApplicationId\" android:value=\"@string/facebook_app_id\" />\n\n <activity android:name=\"com.facebook.FacebookActivity\"\n android:configChanges=\"keyboard|keyboardHidden|screenLayout|screenSize|orientation\"\n android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"\n android:label=\"@string/app_name\" />\n\n <!-- ... -->\n </application>\n\n <!-- ... -->\n</manifest>", "language": "xml" } ] } [/block] ##### Strings [block:code] { "codes": [ { "code": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <string name=\"facebook_app_id\">YOUR_FACEBOOK_APP_ID</string>\n</resources>", "language": "xml" } ] } [/block] #### app.gradle [block:code] { "codes": [ { "code": "buildscript {\n repositories {\n jcenter()\n mavenLocal()\n }\n dependencies {\n classpath 'com.android.tools.build:gradle:2.1.0'\n classpath 'com.google.gms:google-services:3.0.0'\n }\n}\n\nrepositories {\n mavenCentral()\n maven { url 'https://maven.fabric.io/public' }\n}\n\ndependencies {\n compile 'com.facebook.android:facebook-android-sdk:4.6.0'\n compile 'com.google.android.gms:play-services-auth:8.4.0'\n\n compile('com.twitter.sdk.android:twitter:1.13.2@aar') {\n transitive = true\n }\n}", "language": "text" } ] } [/block] ## Usage ### Include [block:code] { "codes": [ { "code": "import SocialLogin = require(\"nativescript-social-login\");", "language": "javascript" } ] } [/block] ### Initialize [block:code] { "codes": [ { "code": "import Application = require(\"application\");\nimport SocialLogin = require(\"nativescript-social-login\");\n\nif (Application.android) {\n Application.android.onActivityCreated = (activity) => {\n var result = SocialLogin.init({\n activity: activity\n });\n });\n}", "language": "javascript" } ] } [/block] ### Login [block:code] { "codes": [ { "code": "SocialLogin.loginWithFacebook(\n (result) => {\n console.log(\"code: \" + result.code);\n console.log(\"error: \" + result.error);\n console.log(\"id: \" + result.id);\n console.log(\"userToken: \" + result.userToken);\n console.log(\"displayName: \" + result.displayName);\n console.log(\"photo: \" + result.photo);\n console.log(\"authToken: \" + result.authToken);\n }\n);", "language": "javascript" } ] } [/block] #### Supported functions [block:parameters] { "data": { "h-0": "Function", "h-1": "Provider", "0-0": "loginWithFacebook", "1-0": "loginWithGoogle", "1-1": "Google", "0-1": "Facebook" }, "cols": 2, "rows": 2 } [/block] ## Logging [block:code] { "codes": [ { "code": "SocialLogin.addLogger(function(msg, tag) {\n console.log('[nativescript-social-login]: (' + tag + '): ' + msg);\n});", "language": "javascript" } ] } [/block]