Permalink
Browse files

Start install script and rearrange things a bit

  • Loading branch information...
1 parent e9cef3b commit f0ae249257e0260d3b5f7b57745ed1cc5c19713f Dave Johnson committed Aug 16, 2011
View
@@ -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/
@@ -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.
@@ -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>
View
@@ -1,16 +0,0 @@
-<widget id="com.phonegap.example" version="0.1.0">
- <name>Example App</name>
- <!--
- TODO feature
- http://api.phonegap.com/1.0/camera
- http://api.phonegap.com/1.0/contacts
- http://api.phonegap.com/1.0/file
- http://api.phonegap.com/1.0/geolocation
- http://api.phonegap.com/1.0/media
- http://api.phonegap.com/1.0/network
- http://api.phonegap.com/1.0/notification
- -->
-    <icon src="img/icon-57.png" width="57" height="57" />
-    <icon src="img/icon-72.png" width="72" height="72" />
-    <icon src="img/icon-114.png" width="114" height="114" />
-</widget>
View
Deleted file not rendered
View
@@ -1,88 +0,0 @@
-<html>
- <head>
- <!-- phonegap -->
- <script src="phonegap-0.9.6.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>
-
- <!-- TODO: have this written dynamically in init if phonegap -->
- <div id="fb-root"></div>
-
- <script>
-
- FB.Event.subscribe('auth.login', function(response) {
- alert('auth.login event');
- });
-
- FB.Event.subscribe('auth.logout', function(response) {
- alert('auth.logout event');
- });
-
- FB.Event.subscribe('auth.sessionChange', function(response) {
- alert('auth.sessionChange event');
- });
-
- FB.Event.subscribe('auth.statusChange', function(response) {
- alert('auth.statusChange event');
- });
-
- function getSession() {
- alert(JSON.stringify(FB.getSession()));
- }
-
- function getLoginStatus() {
- FB.getLoginStatus(function(response) {
- if (response.session) {
- alert('logged in');
- } else {
- alert('not logged in');
- }
- });
- }
-
- function me() {
- FB.api('/me/friends', function(response) {
- alert(JSON.stringify(response));
- });
- }
-
- function logout() {
- FB.logout(function(response) {
- alert('logged out');
- });
- }
-
- function login() {
- FB.login(
- function(e) {
- alert(e);
- },
- { perms: "email" }
- );
- }
-
- 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");
- }, false);
- </script>
- <div id="log"></div>
- </body>
-</html>
@@ -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>
@@ -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>
@@ -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;
@@ -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);
View
@@ -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) {
@@ -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);
+ });
});
}
@@ -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>
@@ -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', []);
}
};
Oops, something went wrong.

0 comments on commit f0ae249

Please sign in to comment.