diff --git a/.gitignore b/.gitignore index 6e13704..ab74ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ -# Xcode +# ObjectiveC https://github.com/github/gitignore/blob/master/Objective-C.gitignore +# OS X .DS_Store -*/build/* + +# Xcode +build/ *.pbxuser !default.pbxuser *.mode1v3 @@ -10,12 +13,66 @@ *.perspectivev3 !default.perspectivev3 xcuserdata +*.xccheckout profile *.moved-aside DerivedData -.idea/ *.hmap -*.xccheckout +*.ipa -#CocoaPods +# CocoaPods Pods + +# Android https://github.com/github/gitignore/blob/master/Android.gitignore +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Ignore gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Eclipse https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore +*.pydevproject +.metadata +.gradle +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +# TeXlipse plugin +.texlipse diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..5383025 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,40 @@ + + + + CordovaFacebook + Cordova plugin that handles Facebook integration in mobile apps. + CCSoft + facebook,cordova,ccsoft + Apache 2.0 License + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/android/CordovaFacebook.java b/src/android/CordovaFacebook.java new file mode 100644 index 0000000..b0ec9f3 --- /dev/null +++ b/src/android/CordovaFacebook.java @@ -0,0 +1,32 @@ +package com.ccsoft.plugin; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONArray; +import org.json.JSONException; + +import android.util.Log; + +public class CordovaFacebook extends CordovaPlugin { + + private final String TAG = "CordovaFacebook"; + + @Override + public boolean execute(String action, JSONArray args, + final CallbackContext callbackContext) throws JSONException { + Log.d(TAG, "action:" + action); + cordova.setActivityResultCallback(this); + + if (action.equals("login")) { + callbackContext.success("login call ok"); + return true; + } + else if (action.equals("logout")) { + callbackContext.success("logout call ok"); + return true; + } + + return false; + } + +} \ No newline at end of file diff --git a/www/CordovaFacebook.js b/www/CordovaFacebook.js new file mode 100644 index 0000000..196979b --- /dev/null +++ b/www/CordovaFacebook.js @@ -0,0 +1,31 @@ +var CC; +(function (CC) { + var CordovaFacebook = (function () { + function CordovaFacebook(appId) { + this.appId = appId; + } + CordovaFacebook.prototype.login = function (successcb, failcb) { + window.cordova.exec(function (response) { + console.log("login call successful"); + if (successcb) + successcb(response); + }, function (err) { + console.log("login call failed with error: " + err); + if (failcb) + failcb(err); + }, "CordovaFacebook", "login", []); + }; + + CordovaFacebook.prototype.logout = function (successcb) { + window.cordova.exec(function (response) { + console.log("logout call successful"); + if (successcb) + successcb(response); + }, function (err) { + console.log(err); + }, "CordovaFacebook", "logout", []); + }; + return CordovaFacebook; + })(); + CC.CordovaFacebook = CordovaFacebook; +})(CC || (CC = {})); diff --git a/www/CordovaFacebook.ts b/www/CordovaFacebook.ts new file mode 100644 index 0000000..c48c509 --- /dev/null +++ b/www/CordovaFacebook.ts @@ -0,0 +1,29 @@ +module CC { + export class CordovaFacebook { + constructor(private appId: string) { + } + + login(successcb?: (r: any) => void, failcb?: (err: any) => void) { + (window).cordova.exec( + (response) => { + console.log("login call successful"); + if (successcb) successcb(response); + }, + (err) => { + console.log("login call failed with error: " + err); + if (failcb) failcb(err); + }, "CordovaFacebook", "login", []); + } + + logout(successcb?: (r: any) => void) { + (window).cordova.exec( + (response) => { + console.log("logout call successful"); + if (successcb) successcb(response); + }, + (err) => { + console.log(err) + }, "CordovaFacebook", "logout", []); + } + } +} \ No newline at end of file