Skip to content

Commit

Permalink
Start install script and rearrange things a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Johnson committed Aug 16, 2011
1 parent e9cef3b commit f0ae249
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 3,883 deletions.
38 changes: 26 additions & 12 deletions README.md
@@ -1,26 +1,40 @@
Facebook Connect PhoneGap Plugin
================================

Offical plugin for Facebook Connect.
This is the offical plugin for Facebook Connect in PhoneGap!

The Facebook Connect plugin for PhoneGap allows you to use the same JavaScript code in your web application as you
use in your native PhoneGap application, but your native PhoneGap application will use the Facebook native app to
perform single sign on (SSO) for the user.

This is all licensed under MIT except for app/www/facebook_js_sdk.js which is the Facebook JS SDK and is Apache 2.0.

Android (OS X)
-----------
Getting Started
---------------

Get the latest Android source from http://github.com/phonegap/phonegap-android and read the readme there about getting started with Android.
Download the latest version of PhoneGap from www.phonegap.com.

From terminal run the following command:
Create an Android or iOS PhoneGap project -- those are the only platforms that the Facebook native application
currently runs on :(

On Android you will need to put the following in your phonegap.xml / plugins.xml file:

<pre>
droidgap gen foobar
&lt;plugin name="com.facebook.phonegap.Connect" value="com.phonegap.facebook.Connect" /&gt;
</pre>

In foobar/res/xml/plugins.xml add the following element as a child of the root plugins element:
http://wiki.phonegap.com/How%20to%20Install%20a%20PhoneGap%20Plugin%20for%20Android

On iOS you will need to put the following in your PhoneGap.plist file:




http://wiki.phonegap.com/How%20to%20Install%20a%20PhoneGap%20Plugin%20for%20iOS




<pre>
&lt;plugin name="com.facebook.phonegap.Connect" value="com.facebook.phonegap.Connect" /&gt;
</pre>

From the PhoneGap Facebook Connect Plugin folder copy the contents of the native/android/ folder into foobar/

Expand All @@ -41,7 +55,7 @@ iOS (Mac OS X)
1. Get the latest iOS source from http://github.com/phonegap/phonegap-iphone and read the README there about getting started with iOS.
2. Create a new Xcode project from the PhoneGap template that you created and installed (you did that if you read the README on github I hope).
3. From the 'PhoneGap Facebook Connect Plugin' folder copy the contents of the native/ios folder into your app in Xcode (usually in the Plugins folder group).
4. Find the PhoneGap.plist file in the project navigator, expand the "Plugins" sub-tree, and add a new entry. For the key, add "com.facebook.phonegap.Connect", and its value will be "FacebookConnectPlugin"
4. Find the PhoneGap.plist file in the project navigator, expand the "Plugins" sub-tree, and add a new entry. For the key, add "com.phonegap.facebook.Connect", and its value will be "FacebookConnectPlugin"
5. From the' PhoneGap Facebook Connect Plugin' folder copy contents of the app/www folder into the www directory in Xcode overwriting the index.html and icon.png files but keeping the phonegap.*.js file
6. for Xcode 4, you will need to build it once, and heed the warning - this is an Xcode 4 template limitation. The warning instructions will tell you to drag copy the www folder into the project in Xcode.
7. Run the application in Xcode.
Expand All @@ -67,4 +81,4 @@ Make sure you add the scheme to your [PROJECTNAME]-Info.plist (located as one of
&lt;/array&gt;
&lt;/dict&gt;
&lt;/array&gt;
</pre>
</pre>
16 changes: 0 additions & 16 deletions app/www/config.xml

This file was deleted.

Binary file removed app/www/icon.png
Binary file not shown.
88 changes: 0 additions & 88 deletions app/www/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions example/iOS/PhoneGapFacebookConnect/PhoneGap.plist
Expand Up @@ -14,6 +14,8 @@
<array/>
<key>Plugins</key>
<dict>
<key>com.phonegap.facebook.Connect</key>
<string>FacebookConnectPlugin</string>
<key>com.phonegap.accelerometer</key>
<string>PGAccelerometer</string>
<key>com.phonegap.camera</key>
Expand All @@ -36,8 +38,6 @@
<string>PGCapture</string>
<key>com.phonegap.notification</key>
<string>PGNotification</string>
<key>com.facebook.phonegap.Connect</key>
<string>FacebookConnectPlugin</string>

</dict>
<key>TopActivityIndicator</key>
Expand Down
38 changes: 8 additions & 30 deletions example/iOS/www/facebook_js_sdk.js
Expand Up @@ -1288,40 +1288,18 @@ FB.provide('', {
return;
}

// if (FB._phonegap) {
// if (a.method == 'permissions.request') {
// // TODO: check wtf b arg is all about...
// PhoneGap.exec(function(e) { // login
// FB.Auth.setSession(e.session, 'connected');
// if (b) b(e);
// }, null, 'com.facebook.phonegap.Connect', 'login', a.perms.split(',') );
// return;
// } else if (a.method == 'auth.logout') { // logout
// PhoneGap.exec(function(e) {
// FB.Auth.setSession(null, 'notConnected');
// if (b) b(e);
// }, null, 'com.facebook.phonegap.Connect', 'logout', []);
// return;
// } else if (a.method == 'auth.status') { // getLoginStatus
// PhoneGap.exec(function(e) {
// if (b) b(e);
// }, null, 'com.facebook.phonegap.Connect', 'getLoginStatus', []);
// return;
// }
// }

// If the phonegap arg is specified then call out to the phonegap plugin
// If the nativeInterface arg is specified then call out to the nativeInterface
// which uses the native app rather than using the iframe / popup web
if (FB._phonegap) {
if (FB._nativeInterface) {
switch (f.method) {
case 'permissions.request':
FB._phonegap.login(b, f);
FB._nativeInterface.login(b, f);
break;
case 'auth.logout':
FB._phonegap.logout(b);
FB._nativeInterface.logout(b);
break;
case 'auth.status':
FB._phonegap.getLoginStatus(b);
FB._nativeInterface.getLoginStatus(b);
break;
}
return;
Expand Down Expand Up @@ -1847,9 +1825,9 @@ FB.provide('', {
status: true
});
FB._apiKey = a.appId || a.apiKey;
FB._phonegap = a.phonegap;
if (FB._phonegap) {
FB._phonegap.init(FB._apiKey);
FB._nativeInterface = a.nativeInterface;
if (FB._nativeInterface) {
FB._nativeInterface.init(FB._apiKey);
}
if (!a.logging && window.location.toString().indexOf('fb_debug=1') < 0) FB._logging = false;
FB.XD.init(a.channelUrl);
Expand Down
40 changes: 22 additions & 18 deletions example/iOS/www/index.html
@@ -1,23 +1,25 @@
<html>
<head>
<!-- phonegap -->
<script src="phonegap-1.0.0rc1.min.js"></script>
<!-- phonegap facebook plugin -->
<script src="pg-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script src="facebook_js_sdk.js"></script>
</head>
<body>
<button onclick="init()">Init</button>
<button onclick="login()">Login</button>
<button onclick="me()">Me</button>
<button onclick="getSession()">Get session</button>
<button onclick="getLoginStatus()">Get login</button>
<button onclick="logout()">Logout</button>


<div id="data"></div>

<!-- TODO: have this written dynamically in init if phonegap -->
<div id="fb-root"></div>

<!-- phonegap -->
<script src="phonegap-1.0.0rc1.min.js"></script>
<!-- phonegap facebook plugin -->
<script src="pg-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script src="facebook_js_sdk.js"></script>

<script>

FB.Event.subscribe('auth.login', function(response) {
Expand Down Expand Up @@ -52,7 +54,12 @@

function me() {
FB.api('/me/friends', function(response) {
alert(JSON.stringify(response));
var data = document.getElementById('data');
response.data.forEach(function(item) {
var d = document.createElement('div');
d.innerHTML = item.name;
data.appendChild(d);
});
});
}

Expand All @@ -71,16 +78,13 @@
);
}

function init() {
try {
FB.init({ appId: "188240441228254", phonegap: PG.FB });
} catch (e) {
alert(e);
}
}

document.addEventListener('deviceready', function() {
navigator.app.addService("com.facebook.phonegap.Connect", "com.facebook.phonegap.ConnectPlugin");
try {
FB.init({ appId: "188240441228254", nativeInterface: PG.FB });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
</script>
<div id="log"></div>
Expand Down
8 changes: 4 additions & 4 deletions example/iOS/www/pg-plugin-fb-connect.js
@@ -1,24 +1,24 @@
PG = ( typeof PG == 'undefined' ? {} : PG );
PG.FB = {
init: function(apiKey) {
PhoneGap.exec(null, null, 'com.facebook.phonegap.Connect', 'init', [apiKey]);
PhoneGap.exec(null, null, 'com.phonegap.facebook.Connect', 'init', [apiKey]);
},
login: function(a, b) {
b = b || { perms: '' };
PhoneGap.exec(function(e) { // login
FB.Auth.setSession(e.session, 'connected');
if (a) a(e);
}, null, 'com.facebook.phonegap.Connect', 'login', b.perms.split(',') );
}, null, 'com.phonegap.facebook.Connect', 'login', b.perms.split(',') );
},
logout: function(cb) {
PhoneGap.exec(function(e) {
FB.Auth.setSession(null, 'notConnected');
if (cb) cb(e);
}, null, 'com.facebook.phonegap.Connect', 'logout', []);
}, null, 'com.phonegap.facebook.Connect', 'logout', []);
},
getLoginStatus: function(cb) {
PhoneGap.exec(function(e) {
if (cb) cb(e);
}, null, 'com.facebook.phonegap.Connect', 'getLoginStatus', []);
}, null, 'com.phonegap.facebook.Connect', 'getLoginStatus', []);
}
};

0 comments on commit f0ae249

Please sign in to comment.