Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Echo-like plugin flow implemented for android.
- Loading branch information
1 parent
303cf95
commit 9e071df
Showing
5 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
id="com.ccsoft.plugin.CordovaFacebook" | ||
version="1.0.0"> | ||
|
||
<name>CordovaFacebook</name> | ||
<description>Cordova plugin that handles Facebook integration in mobile apps.</description> | ||
<author>CCSoft</author> | ||
<keywords>facebook,cordova,ccsoft</keywords> | ||
<license>Apache 2.0 License</license> | ||
|
||
<engines> | ||
<engine name="cordova" version=">=3.0.0" /> | ||
</engines> | ||
|
||
<asset src="www/CordovaFacebook.js" target="plugins/CordovaFacebook.js" /> | ||
|
||
<!-- android --> | ||
<platform name="android"> | ||
|
||
<source-file src="src/android/CordovaFacebook.java" | ||
target-dir="src/com/ccsoft/plugin" /> | ||
|
||
<config-file target="AndroidManifest.xml" parent="/*/application"> | ||
<activity android:label="@string/app_name" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" /> | ||
</config-file> | ||
|
||
<config-file target="config.xml" parent="/*"> | ||
<feature name="CordovaFacebook"> | ||
<param name="android-package" value="com.ccsoft.plugin.CordovaFacebook" /> | ||
</feature> | ||
|
||
</config-file> | ||
|
||
</platform> | ||
|
||
|
||
</plugin> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module CC { | ||
export class CordovaFacebook { | ||
constructor(private appId: string) { | ||
} | ||
|
||
login(successcb?: (r: any) => void, failcb?: (err: any) => void) { | ||
(<any>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) { | ||
(<any>window).cordova.exec( | ||
(response) => { | ||
console.log("logout call successful"); | ||
if (successcb) successcb(response); | ||
}, | ||
(err) => { | ||
console.log(err) | ||
}, "CordovaFacebook", "logout", []); | ||
} | ||
} | ||
} |