Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Final plugin fix #3

Merged
merged 4 commits into from

2 participants

This page is out of date. Refresh to see the latest.
View
19 README.md
@@ -13,3 +13,22 @@ simply run:
./run-tests
The tests can be found in `./test/www/facebook-connect-tests.js`.
+
+iOS Testing
+-----------
+
+Make sure you add the scheme to your [PROJECTNAME]-Info.plist, substitute [APP_ID] and [SCHEME_ID] below to the appropriate values. This is to handle the re-direct from Mobile Safari, after permission authorization.
+
+<pre>
+&lt;key&gt;CFBundleURLTypes&lt;/key&gt;
+&lt;array&gt;
+ &lt;dict&gt;
+ &lt;key&gt;CFBundleURLName&lt;/key&gt;
+ &lt;string&gt;[SCHEME_ID]&lt;/string&gt;
+ &lt;key&gt;CFBundleURLSchemes&lt;/key&gt;
+ &lt;array&gt;
+ &lt;string&gt;fb[APP_ID]&lt;/string&gt;
+ &lt;/array&gt;
+ &lt;/dict&gt;
+&lt;/array&gt;
+</pre>
View
10 native/ios/FacebookConnectPlugin.h 100644 → 100755
@@ -7,13 +7,15 @@
//
#import <Foundation/Foundation.h>
-#import "PhoneGapCommand.h"
+#ifdef PHONEGAP_FRAMEWORK
+ #import <PhoneGap/PGPlugin.h>
+#else
+ #import "PGPlugin.h"
+#endif
#import "FBConnect.h"
-@interface FacebookConnectPlugin : PhoneGapCommand<FBSessionDelegate,FBRequestDelegate,FBDialogDelegate> {
-
- Facebook *facebook;
+@interface FacebookConnectPlugin : PGPlugin<FBSessionDelegate,FBRequestDelegate,FBDialogDelegate> {
}
@property (nonatomic, retain) Facebook *facebook;
View
111 native/ios/FacebookConnectPlugin.m 100644 → 100755
@@ -7,46 +7,119 @@
//
#import "FacebookConnectPlugin.h"
-#import "JSON.h"
+#ifdef PHONEGAP_FRAMEWORK
+ #import <PhoneGap/JSON.h>
+ #import <PhoneGap/PluginResult.h>
+#else
+ #import "JSON.h"
+ #import "PluginResult.h"
+#endif
+#define APP_SECRET @"b082c4620cdac27e0371f2c674026662"
@implementation FacebookConnectPlugin
@synthesize facebook;
+/* This overrides PGPlugin's method, which receives a notification when handleOpenURL is called on the main app delegate */
+- (void) handleOpenURL:(NSNotification*)notification
+{
+ NSURL* url = [notification object];
+ if (![url isKindOfClass:[NSURL class]]) {
+ return;
+ }
+
+ BOOL ok = [facebook handleOpenURL:url];
+ if (ok) {
+
+ NSDictionary* session = [NSDictionary
+ dictionaryWithObjects:[NSArray arrayWithObjects:self.facebook.accessToken, [self.facebook.expirationDate description], APP_SECRET, [NSNumber numberWithBool:YES], @"...", @"...", nil]
+ forKeys:[NSArray arrayWithObjects:@"access_token", @"expires", @"secret", @"session_key", @"sig", @"uid", nil]];
+
+ [super writeJavascript:[NSString stringWithFormat:@"FB.Auth.setSession(%@);", [session JSONRepresentation]]];
+ }
+}
-- (void) initWithAppId:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+- (void) init:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
- NSString* appId = [arguments objectAtIndex:0];
- facebook = [[Facebook alloc] initWithAppId:appId];
-
-// TODO: pass in permissions
-// NSArray* permissions = [[NSArray arrayWithObjects:
-// @"email", @"read_stream", nil] retain];
-//
-//
-// [facebook authorize:permissions delegate:self];
+ if ([arguments count] < 2) {
+ return;
+ }
+
+ NSString* callbackId = [arguments objectAtIndex:0];
+ NSString* appId = [arguments objectAtIndex:1];
+ self.facebook = [[Facebook alloc] initWithAppId:appId];
+
+ PluginResult* result = [PluginResult resultWithStatus:PGCommandStatus_OK];
+ [super writeJavascript:[result toSuccessCallbackString:callbackId]];
}
--(void) authorize:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+- (void) getLoginStatus:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
- [facebook authorize:arguments delegate:self];
+ NSString* callbackId = [arguments objectAtIndex:0];// first item is the callbackId
+
+ PluginResult* result = [PluginResult resultWithStatus:self.facebook? PGCommandStatus_OK : PGCommandStatus_ERROR];
+ [super writeJavascript:[result toSuccessCallbackString:callbackId]];
}
--(void) logout:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+- (void) login:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
- [facebook logout:self];
+ if ([arguments count] < 2 || !self.facebook) {
+ return;
+ }
+
+ NSString* callbackId = [arguments objectAtIndex:0];// first item is the callbackId
+ BOOL validSession = [self.facebook isSessionValid];
+
+ PluginResult* result = nil;
+ NSString* jsString = nil;
+
+ if (validSession)
+ {
+ result = [PluginResult resultWithStatus:PGCommandStatus_OK];
+ jsString = [result toSuccessCallbackString:callbackId];
+
+ } else {
+ NSMutableArray* marray = [NSMutableArray arrayWithArray:arguments];
+ [marray removeObjectAtIndex:0]; // first item is the callbackId
+
+ [facebook authorize:marray delegate:self];
+
+ result = [PluginResult resultWithStatus:PGCommandStatus_ERROR messageAsString:@"Must call FB.init before FB.login"];
+ jsString = [result toErrorCallbackString:callbackId];
+ }
+
+ [super writeJavascript:jsString];
}
--(void) handleOpenUrl:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+- (void) logout:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
- NSURL* url = [NSURL URLWithString:[arguments objectAtIndex:0]];
- [facebook handleOpenURL:url];
+ if (!self.facebook) {
+ return;
+ }
+
+ NSString* callbackId = [arguments objectAtIndex:0];// first item is the callbackId
+
+ [facebook logout:self];
+
+ PluginResult* result = [PluginResult resultWithStatus:PGCommandStatus_OK];
+ [super writeJavascript:[result toSuccessCallbackString:callbackId]];
}
--(void) showFeedPublishDialog:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+- (void) showFeedPublishDialog:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
+ NSString* callbackId = [arguments objectAtIndex:0];// first item is the callbackId
+
[facebook dialog:@"feed" andDelegate:self];
+
+ PluginResult* result = [PluginResult resultWithStatus:PGCommandStatus_NO_RESULT];
+ [super writeJavascript:[result toSuccessCallbackString:callbackId]];
+}
+
+- (void) dealloc
+{
+ self.facebook = nil;
+ [super dealloc];
}
/**
View
45 www/facebook-connect-0.0.1.js 100644 → 100755
@@ -1,27 +1,42 @@
PG = ( typeof PG == 'undefined' ? {} : PG );
-PG.FB: {
+PG.FB = {
init: function(apiKey) {
- PhoneGap.exec(null, null, 'com.facebook.phonegap.Connect', 'init', [apiKey]);
+ PhoneGap.exec(function(e) {
+ console.log("init: " + e);
+ }, null, 'com.facebook.phonegap.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(',') );
+ try {
+ b = b || { perms: '' };
+ PhoneGap.exec(function(e) { // login
+ //FB.Auth.setSession(e.session, 'connected'); // never gets called because the plugin spawns Mobile Safari/Facebook app
+ if (a) a(e);
+ }, null, 'com.facebook.phonegap.Connect', 'login', b.perms.split(',') );
+ } catch (e) {
+ alert(e);
+ }
},
logout: function(cb) {
- PhoneGap.exec(function(e) {
- FB.Auth.setSession(null, 'notConnected');
- if (cb) cb(e);
- }, null, 'com.facebook.phonegap.Connect', 'logout', []);
+ try {
+ PhoneGap.exec(function(e) {
+ FB.Auth.setSession(null, 'notConnected');
+ if (cb) cb(e);
+ }, null, 'com.facebook.phonegap.Connect', 'logout', []);
+ } catch (e) {
+ alert(e);
+ }
},
getLoginStatus: function(cb) {
- PhoneGap.exec(function(e) {
- if (cb) cb(e);
- }, null, 'com.facebook.phonegap.Connect', 'getLoginStatus', []);
+ try {
+ PhoneGap.exec(function(e) {
+ if (cb) cb(e);
+ console.log("getLoginStatus: " + e);
+ }, null, 'com.facebook.phonegap.Connect', 'getLoginStatus', []);
+ } catch (e) {
+ alert(e);
+ }
},
isAppInstalled: function(cb) {
}
-};
+};
View
59 www/facebook.js 100644 → 100755
@@ -1288,27 +1288,45 @@ 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
+ // which uses the native app rather than using the iframe / popup web
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;
+ switch (f.method) {
+ case 'permissions.request':
+ FB._phonegap.login(b, f);
+ break;
+ case 'auth.logout':
+ FB._phonegap.logout(b);
+ break;
+ case 'auth.status':
+ FB._phonegap.getLoginStatus(b);
+ break;
}
+ return;
}
+
if (f.method == 'permissions.request' && (f.display == 'iframe' || f.display == 'dialog')) {
var h = f.perms.split(',');
@@ -1679,6 +1697,8 @@ FB.provide('Auth', {
};
}
});
+
+
FB.provide('UIServer.Methods', {
'permissions.request': {
size: {
@@ -4527,4 +4547,5 @@ FB.provide("XFBML.ProfilePic", {
}, true);
if (FB.Dom && FB.Dom.addCssRules) {
FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size: 11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_advanced.fb_mobile{background:rgba(82, 82, 82, .7);padding:4px;-moz-border-radius:2px;-webkit-border-radius:2px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_mobile .fb_dialog_close_icon{top:11px\n}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size: 24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size: 14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size: 24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size: 13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size: 11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size: 10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size: 10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size: 22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size: 10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size: 11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size: 13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size: 13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size: 11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0;z-index:1}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:0;top:1px;margin-top:6px;margin-left:0;background-position:50\u0025 50\u0025;background-color:#fff;height:150px;width:394px;border:1px #666 solid;border-bottom:2px solid #283e6c;z-index:1}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget.dark .FB_Loader{background-color:#000;border-bottom:2px solid #ccc}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget.siderender\n.FB_Loader{margin-top:0}\n#fb_social_bar_container{position:fixed;left:0;right:0;height:34px;padding:0 25px;z-index:999999999}\n.fb_social_bar_iframe{position:relative;float:right;opacity:0;-moz-opacity:0;filter:alpha(opacity=0)}\n.fb_social_bar_iframe_bottom_ie6{bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)))}\n.fb_social_bar_iframe_top_ie6{bottom:auto;top:expression(eval(document.documentElement.scrollTop-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)))}\n", ["fb.css.base", "fb.css.dialog", "fb.css.iframewidget", "fb.css.button", "fb.css.sharebutton", "fb.css.connectbarwidget", "fb.css.edgecommentwidget", "fb.css.sendbuttonformwidget", "fb.css.socialbarwidget"]);
-}
+}
+
View
105 www/index.html 100644 → 100755
@@ -1,5 +1,14 @@
<html>
- <head></head>
+ <head>
+ <!-- phonegap -->
+ <script src="phonegap-0.9.6.js"></script>
+ <!-- phonegap facebook plugin -->
+ <script src="facebook-connect-0.0.1.js"></script>
+ <!-- weinre -->
+ <script src="http://debug.phonegap.com/target/target-script-min.js#foobook"></script>
+ <!-- facebook js sdk -->
+ <script src="facebook.js"></script>
+ </head>
<body>
<button onclick="init()">Init</button>
<button onclick="login()">Login</button>
@@ -11,29 +20,63 @@
<!-- TODO: have this written dynamically in init if phonegap -->
<div id="fb-root"></div>
- <!-- phonegap -->
- <script src="phonegap.0.9.5.js"></script>
- <!-- phonegap facebook plugin -->
- <script src="facebook-connect-0.0.1.js"></script>
- <!-- weinre -->
- <script src="http://debug.phonegap.com/target/target-script-min.js#foobook"></script>
- <!-- facebook js sdk -->
- <script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
+
+ ///////////////////////////////////////////////////////////////////////////
+ // We write results to the DOM because of handleOpenURL restrictions
+
+ var lastTime = null;
+ function writeTimestamp()
+ {
+ var now = new Date().getTime();
+ if (lastTime == null) {
+ lastTime = new Date(now);
+ }
+
+ var elapsed = now - lastTime;
+ if (elapsed > 10000 || elapsed == 0) {
+ write("<hr />");
+ writeln(new Date(now).toString());
+ if (elapsed != 0) {
+ lastTime = new Date(now);
+ }
+ }
+ }
+
+ function writeLog(str)
+ {
+ writeTimestamp();
+ writeln(str);
+ }
+
+ function write(str)
+ {
+ var el = document.getElementById("log");
+ el.innerHTML = el.innerHTML + str;
+ el.scrollTop = el.scrollHeight;
+ }
+
+ function writeln(str)
+ {
+ write(str + '<br />');
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+
FB.Event.subscribe('auth.login', function(response) {
- alert('auth.login event');
+ writeLog('auth.login event');
});
FB.Event.subscribe('auth.logout', function(response) {
- alert('auth.login event');
+ writeLog('auth.logout event');
});
FB.Event.subscribe('auth.sessionChange', function(response) {
- alert('auth.sessionChange event');
+ writeLog('auth.sessionChange event');
});
FB.Event.subscribe('auth.statusChange', function(response) {
- alert('auth.statusChange event');
+ writeLog('auth.statusChange event');
});
function getSession() {
@@ -42,41 +85,47 @@
function getLoginStatus() {
FB.getLoginStatus(function(response) {
- if (response.session) {
- alert('logged in');
- } else {
- alert('not logged in');
- }
+ if (response.session) {
+ alert('logged in');
+ } else {
+ alert('not logged in');
+ }
});
}
function me() {
FB.api('/me/friends', function(response) {
- alert(JSON.stringify(response));
+ alert(JSON.stringify(response));
});
}
function logout() {
FB.logout(function(response) {
- alert('logged out');
+ alert('logged out');
});
}
function login() {
- FB.login(
- function(e) {alert('success');},
- function(e) {console.log('fail'); console.log(e)},
- ["email"]
- );
+ FB.login(
+ function(e) {
+ alert(e);
+ },
+ { perms: "email" }
+ );
}
function init() {
- FB.init({ appId: "188240441228254", phonegap: PG.FB });
+ 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");
+ navigator.app.addService("com.facebook.phonegap.Connect", "com.facebook.phonegap.ConnectPlugin");
}, false);
</script>
+ <div id="log"></div>
</body>
</html>
Something went wrong with that request. Please try again.