Browse files

iOS Example, using PhoneGap 1.0.0rc1

  • Loading branch information...
1 parent 308b588 commit 52bb9fbe41c1b250527994a99c2cd7e4270e8fe4 @shazron shazron committed Jul 15, 2011
Showing with 11,701 additions and 0 deletions.
  1. +508 −0 example/iOS/PhoneGapFacebookConnect.xcodeproj/project.pbxproj
  2. +29 −0 example/iOS/PhoneGapFacebookConnect/Classes/AppDelegate.h
  3. +111 −0 example/iOS/PhoneGapFacebookConnect/Classes/AppDelegate.m
  4. +46 −0 example/iOS/PhoneGapFacebookConnect/PhoneGap.plist
  5. +60 −0 example/iOS/PhoneGapFacebookConnect/PhoneGapFacebookConnect-Info.plist
  6. +8 −0 example/iOS/PhoneGapFacebookConnect/PhoneGapFacebookConnect-Prefix.pch
  7. +27 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBConnect.h
  8. BIN example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.bundle/images/close.png
  9. BIN example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.bundle/images/fbicon.png
  10. +167 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.h
  11. +656 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.m
  12. +48 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBLoginDialog.h
  13. +94 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBLoginDialog.m
  14. +116 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBRequest.h
  15. +367 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBRequest.m
  16. +109 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/Facebook.h
  17. +606 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/Facebook.m
  18. +7 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/facebook_ios_sdk_Prefix.pch
  19. +24 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FacebookConnectPlugin.h
  20. +307 −0 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FacebookConnectPlugin.m
  21. +1 −0 example/iOS/PhoneGapFacebookConnect/Plugins/README
  22. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/controls_bg.png
  23. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/controls_bg@2x.png
  24. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/controls_bg~ipad.png
  25. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/microphone.png
  26. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/microphone@2x.png
  27. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/microphone~ipad.png
  28. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/record_button.png
  29. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/record_button@2x.png
  30. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/record_button~ipad.png
  31. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/recording_bg.png
  32. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/recording_bg@2x.png
  33. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/recording_bg~ipad.png
  34. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/stop_button.png
  35. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/stop_button@2x.png
  36. BIN example/iOS/PhoneGapFacebookConnect/Resources/Capture.bundle/stop_button~ipad.png
  37. +10 −0 example/iOS/PhoneGapFacebookConnect/Resources/en.lproj/Localizable.strings
  38. +9 −0 example/iOS/PhoneGapFacebookConnect/Resources/es.lproj/Localizable.strings
  39. BIN example/iOS/PhoneGapFacebookConnect/Resources/icons/icon-72.png
  40. BIN example/iOS/PhoneGapFacebookConnect/Resources/icons/icon.png
  41. BIN example/iOS/PhoneGapFacebookConnect/Resources/icons/icon@2x.png
  42. BIN example/iOS/PhoneGapFacebookConnect/Resources/splash/Default.png
  43. BIN example/iOS/PhoneGapFacebookConnect/Resources/splash/Default@2x.png
  44. BIN example/iOS/PhoneGapFacebookConnect/Resources/splash/Default~ipad.png
  45. +2 −0 example/iOS/PhoneGapFacebookConnect/en.lproj/InfoPlist.strings
  46. +17 −0 example/iOS/PhoneGapFacebookConnect/main.m
  47. +24 −0 example/iOS/www/facebook-connect-0.0.1.js
  48. +4,551 −0 example/iOS/www/facebook.js
  49. BIN example/iOS/www/icon.png
  50. +130 −0 example/iOS/www/index.html
  51. +3,666 −0 example/iOS/www/phonegap-1.0.0rc1.js
  52. +1 −0 example/iOS/www/phonegap-1.0.0rc1.min.js
View
508 example/iOS/PhoneGapFacebookConnect.xcodeproj/project.pbxproj
@@ -0,0 +1,508 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 30C359BE13C51E060019EFCA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359BD13C51E060019EFCA /* Foundation.framework */; };
+ 30C359C013C51E060019EFCA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359BF13C51E060019EFCA /* UIKit.framework */; };
+ 30C359C213C51E060019EFCA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359C113C51E060019EFCA /* CoreGraphics.framework */; };
+ 30C359C413C51E060019EFCA /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359C313C51E060019EFCA /* AddressBook.framework */; };
+ 30C359C613C51E060019EFCA /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359C513C51E060019EFCA /* AddressBookUI.framework */; };
+ 30C359C813C51E060019EFCA /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359C713C51E060019EFCA /* AudioToolbox.framework */; };
+ 30C359CA13C51E060019EFCA /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359C913C51E060019EFCA /* AVFoundation.framework */; };
+ 30C359CC13C51E060019EFCA /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359CB13C51E060019EFCA /* CoreLocation.framework */; };
+ 30C359CE13C51E060019EFCA /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359CD13C51E060019EFCA /* MediaPlayer.framework */; };
+ 30C359D013C51E060019EFCA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359CF13C51E060019EFCA /* QuartzCore.framework */; };
+ 30C359D213C51E060019EFCA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359D113C51E060019EFCA /* SystemConfiguration.framework */; };
+ 30C359D413C51E060019EFCA /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359D313C51E060019EFCA /* MobileCoreServices.framework */; };
+ 30C359D613C51E060019EFCA /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359D513C51E060019EFCA /* CoreMedia.framework */; };
+ 30C359DC13C51E060019EFCA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30C359DA13C51E060019EFCA /* InfoPlist.strings */; };
+ 30C359DF13C51E060019EFCA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C359DE13C51E060019EFCA /* main.m */; };
+ 30C359E113C51E060019EFCA /* PhoneGap.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30C359E013C51E060019EFCA /* PhoneGap.framework */; };
+ 30C359E613C51E060019EFCA /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30C359E413C51E060019EFCA /* Localizable.strings */; };
+ 30C359EA13C51E060019EFCA /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30C359E813C51E060019EFCA /* Localizable.strings */; };
+ 30C359ED13C51E060019EFCA /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 30C359EC13C51E060019EFCA /* icon.png */; };
+ 30C359EF13C51E060019EFCA /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30C359EE13C51E060019EFCA /* icon@2x.png */; };
+ 30C359F113C51E060019EFCA /* icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 30C359F013C51E060019EFCA /* icon-72.png */; };
+ 30C359F413C51E060019EFCA /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 30C359F313C51E060019EFCA /* Default.png */; };
+ 30C359F613C51E060019EFCA /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30C359F513C51E060019EFCA /* Default@2x.png */; };
+ 30C359F813C51E060019EFCA /* Default~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 30C359F713C51E060019EFCA /* Default~ipad.png */; };
+ 30C359FA13C51E060019EFCA /* Capture.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 30C359F913C51E060019EFCA /* Capture.bundle */; };
+ 30C359FC13C51E060019EFCA /* PhoneGap.plist in Resources */ = {isa = PBXBuildFile; fileRef = 30C359FB13C51E060019EFCA /* PhoneGap.plist */; };
+ 30C35A0013C51E060019EFCA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C359FF13C51E060019EFCA /* AppDelegate.m */; };
+ 30C35A0913C51E290019EFCA /* www in Resources */ = {isa = PBXBuildFile; fileRef = 30C35A0813C51E290019EFCA /* www */; };
+ 30C35A1913C51E5E0019EFCA /* FacebookConnectPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C35A0C13C51E5E0019EFCA /* FacebookConnectPlugin.m */; };
+ 30C35A1A13C51E5E0019EFCA /* Facebook.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C35A0F13C51E5E0019EFCA /* Facebook.m */; };
+ 30C35A1B13C51E5E0019EFCA /* FBDialog.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 30C35A1213C51E5E0019EFCA /* FBDialog.bundle */; };
+ 30C35A1C13C51E5E0019EFCA /* FBDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C35A1413C51E5E0019EFCA /* FBDialog.m */; };
+ 30C35A1D13C51E5E0019EFCA /* FBLoginDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C35A1613C51E5E0019EFCA /* FBLoginDialog.m */; };
+ 30C35A1E13C51E5E0019EFCA /* FBRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C35A1813C51E5E0019EFCA /* FBRequest.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 30C359B913C51E060019EFCA /* PhoneGapFacebookConnect.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PhoneGapFacebookConnect.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 30C359BD13C51E060019EFCA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 30C359BF13C51E060019EFCA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 30C359C113C51E060019EFCA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 30C359C313C51E060019EFCA /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
+ 30C359C513C51E060019EFCA /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; };
+ 30C359C713C51E060019EFCA /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
+ 30C359C913C51E060019EFCA /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
+ 30C359CB13C51E060019EFCA /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
+ 30C359CD13C51E060019EFCA /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
+ 30C359CF13C51E060019EFCA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ 30C359D113C51E060019EFCA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
+ 30C359D313C51E060019EFCA /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
+ 30C359D513C51E060019EFCA /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
+ 30C359D913C51E060019EFCA /* PhoneGapFacebookConnect-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PhoneGapFacebookConnect-Info.plist"; sourceTree = "<group>"; };
+ 30C359DB13C51E060019EFCA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 30C359DD13C51E060019EFCA /* PhoneGapFacebookConnect-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PhoneGapFacebookConnect-Prefix.pch"; sourceTree = "<group>"; };
+ 30C359DE13C51E060019EFCA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 30C359E013C51E060019EFCA /* PhoneGap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhoneGap.framework; path = /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework; sourceTree = "<absolute>"; };
+ 30C359E513C51E060019EFCA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localizable.strings; sourceTree = "<group>"; };
+ 30C359E913C51E060019EFCA /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Resources/es.lproj/Localizable.strings; sourceTree = "<group>"; };
+ 30C359EC13C51E060019EFCA /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon.png; path = Resources/icons/icon.png; sourceTree = "<group>"; };
+ 30C359EE13C51E060019EFCA /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon@2x.png"; path = "Resources/icons/icon@2x.png"; sourceTree = "<group>"; };
+ 30C359F013C51E060019EFCA /* icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-72.png"; path = "Resources/icons/icon-72.png"; sourceTree = "<group>"; };
+ 30C359F313C51E060019EFCA /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = Resources/splash/Default.png; sourceTree = "<group>"; };
+ 30C359F513C51E060019EFCA /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "Resources/splash/Default@2x.png"; sourceTree = "<group>"; };
+ 30C359F713C51E060019EFCA /* Default~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default~ipad.png"; path = "Resources/splash/Default~ipad.png"; sourceTree = "<group>"; };
+ 30C359F913C51E060019EFCA /* Capture.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Capture.bundle; path = Resources/Capture.bundle; sourceTree = "<group>"; };
+ 30C359FB13C51E060019EFCA /* PhoneGap.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = PhoneGap.plist; sourceTree = "<group>"; };
+ 30C359FE13C51E060019EFCA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Classes/AppDelegate.h; sourceTree = "<group>"; };
+ 30C359FF13C51E060019EFCA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Classes/AppDelegate.m; sourceTree = "<group>"; };
+ 30C35A0213C51E060019EFCA /* README */ = {isa = PBXFileReference; lastKnownFileType = text; name = README; path = Plugins/README; sourceTree = "<group>"; };
+ 30C35A0813C51E290019EFCA /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = "<group>"; };
+ 30C35A0B13C51E5E0019EFCA /* FacebookConnectPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FacebookConnectPlugin.h; sourceTree = "<group>"; };
+ 30C35A0C13C51E5E0019EFCA /* FacebookConnectPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FacebookConnectPlugin.m; sourceTree = "<group>"; };
+ 30C35A0E13C51E5E0019EFCA /* Facebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Facebook.h; sourceTree = "<group>"; };
+ 30C35A0F13C51E5E0019EFCA /* Facebook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Facebook.m; sourceTree = "<group>"; };
+ 30C35A1013C51E5E0019EFCA /* facebook_ios_sdk_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = facebook_ios_sdk_Prefix.pch; sourceTree = "<group>"; };
+ 30C35A1113C51E5E0019EFCA /* FBConnect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBConnect.h; sourceTree = "<group>"; };
+ 30C35A1213C51E5E0019EFCA /* FBDialog.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = FBDialog.bundle; sourceTree = "<group>"; };
+ 30C35A1313C51E5E0019EFCA /* FBDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBDialog.h; sourceTree = "<group>"; };
+ 30C35A1413C51E5E0019EFCA /* FBDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBDialog.m; sourceTree = "<group>"; };
+ 30C35A1513C51E5E0019EFCA /* FBLoginDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBLoginDialog.h; sourceTree = "<group>"; };
+ 30C35A1613C51E5E0019EFCA /* FBLoginDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBLoginDialog.m; sourceTree = "<group>"; };
+ 30C35A1713C51E5E0019EFCA /* FBRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBRequest.h; sourceTree = "<group>"; };
+ 30C35A1813C51E5E0019EFCA /* FBRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBRequest.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 30C359B313C51E060019EFCA /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 30C359BE13C51E060019EFCA /* Foundation.framework in Frameworks */,
+ 30C359C013C51E060019EFCA /* UIKit.framework in Frameworks */,
+ 30C359C213C51E060019EFCA /* CoreGraphics.framework in Frameworks */,
+ 30C359C413C51E060019EFCA /* AddressBook.framework in Frameworks */,
+ 30C359C613C51E060019EFCA /* AddressBookUI.framework in Frameworks */,
+ 30C359C813C51E060019EFCA /* AudioToolbox.framework in Frameworks */,
+ 30C359CA13C51E060019EFCA /* AVFoundation.framework in Frameworks */,
+ 30C359CC13C51E060019EFCA /* CoreLocation.framework in Frameworks */,
+ 30C359CE13C51E060019EFCA /* MediaPlayer.framework in Frameworks */,
+ 30C359D013C51E060019EFCA /* QuartzCore.framework in Frameworks */,
+ 30C359D213C51E060019EFCA /* SystemConfiguration.framework in Frameworks */,
+ 30C359D413C51E060019EFCA /* MobileCoreServices.framework in Frameworks */,
+ 30C359D613C51E060019EFCA /* CoreMedia.framework in Frameworks */,
+ 30C359E113C51E060019EFCA /* PhoneGap.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 30C359B613C51E060019EFCA /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 30C359AB13C51E060019EFCA = {
+ isa = PBXGroup;
+ children = (
+ 30C35A0813C51E290019EFCA /* www */,
+ 30C359D713C51E060019EFCA /* PhoneGapFacebookConnect */,
+ 30C359BC13C51E060019EFCA /* Frameworks */,
+ 30C359BA13C51E060019EFCA /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 30C359BA13C51E060019EFCA /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359B913C51E060019EFCA /* PhoneGapFacebookConnect.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 30C359BC13C51E060019EFCA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359BD13C51E060019EFCA /* Foundation.framework */,
+ 30C359BF13C51E060019EFCA /* UIKit.framework */,
+ 30C359C113C51E060019EFCA /* CoreGraphics.framework */,
+ 30C359C313C51E060019EFCA /* AddressBook.framework */,
+ 30C359C513C51E060019EFCA /* AddressBookUI.framework */,
+ 30C359C713C51E060019EFCA /* AudioToolbox.framework */,
+ 30C359C913C51E060019EFCA /* AVFoundation.framework */,
+ 30C359CB13C51E060019EFCA /* CoreLocation.framework */,
+ 30C359CD13C51E060019EFCA /* MediaPlayer.framework */,
+ 30C359CF13C51E060019EFCA /* QuartzCore.framework */,
+ 30C359D113C51E060019EFCA /* SystemConfiguration.framework */,
+ 30C359D313C51E060019EFCA /* MobileCoreServices.framework */,
+ 30C359D513C51E060019EFCA /* CoreMedia.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 30C359D713C51E060019EFCA /* PhoneGapFacebookConnect */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359E013C51E060019EFCA /* PhoneGap.framework */,
+ 30C359E213C51E060019EFCA /* Resources */,
+ 30C359FD13C51E060019EFCA /* Classes */,
+ 30C35A0113C51E060019EFCA /* Plugins */,
+ 30C359D813C51E060019EFCA /* Supporting Files */,
+ );
+ path = PhoneGapFacebookConnect;
+ sourceTree = "<group>";
+ };
+ 30C359D813C51E060019EFCA /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359D913C51E060019EFCA /* PhoneGapFacebookConnect-Info.plist */,
+ 30C359DA13C51E060019EFCA /* InfoPlist.strings */,
+ 30C359DD13C51E060019EFCA /* PhoneGapFacebookConnect-Prefix.pch */,
+ 30C359DE13C51E060019EFCA /* main.m */,
+ 30C359FB13C51E060019EFCA /* PhoneGap.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 30C359E213C51E060019EFCA /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359F913C51E060019EFCA /* Capture.bundle */,
+ 30C359E313C51E060019EFCA /* en.lproj */,
+ 30C359E713C51E060019EFCA /* es.lproj */,
+ 30C359EB13C51E060019EFCA /* icons */,
+ 30C359F213C51E060019EFCA /* splash */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ 30C359E313C51E060019EFCA /* en.lproj */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359E413C51E060019EFCA /* Localizable.strings */,
+ );
+ name = en.lproj;
+ sourceTree = "<group>";
+ };
+ 30C359E713C51E060019EFCA /* es.lproj */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359E813C51E060019EFCA /* Localizable.strings */,
+ );
+ name = es.lproj;
+ sourceTree = "<group>";
+ };
+ 30C359EB13C51E060019EFCA /* icons */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359EC13C51E060019EFCA /* icon.png */,
+ 30C359EE13C51E060019EFCA /* icon@2x.png */,
+ 30C359F013C51E060019EFCA /* icon-72.png */,
+ );
+ name = icons;
+ sourceTree = "<group>";
+ };
+ 30C359F213C51E060019EFCA /* splash */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359F313C51E060019EFCA /* Default.png */,
+ 30C359F513C51E060019EFCA /* Default@2x.png */,
+ 30C359F713C51E060019EFCA /* Default~ipad.png */,
+ );
+ name = splash;
+ sourceTree = "<group>";
+ };
+ 30C359FD13C51E060019EFCA /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ 30C359FE13C51E060019EFCA /* AppDelegate.h */,
+ 30C359FF13C51E060019EFCA /* AppDelegate.m */,
+ );
+ name = Classes;
+ sourceTree = "<group>";
+ };
+ 30C35A0113C51E060019EFCA /* Plugins */ = {
+ isa = PBXGroup;
+ children = (
+ 30C35A0A13C51E5E0019EFCA /* FBPlugin */,
+ 30C35A0213C51E060019EFCA /* README */,
+ );
+ name = Plugins;
+ sourceTree = "<group>";
+ };
+ 30C35A0A13C51E5E0019EFCA /* FBPlugin */ = {
+ isa = PBXGroup;
+ children = (
+ 30C35A0B13C51E5E0019EFCA /* FacebookConnectPlugin.h */,
+ 30C35A0C13C51E5E0019EFCA /* FacebookConnectPlugin.m */,
+ 30C35A0D13C51E5E0019EFCA /* FB_src */,
+ );
+ name = FBPlugin;
+ path = Plugins/FBPlugin;
+ sourceTree = "<group>";
+ };
+ 30C35A0D13C51E5E0019EFCA /* FB_src */ = {
+ isa = PBXGroup;
+ children = (
+ 30C35A0E13C51E5E0019EFCA /* Facebook.h */,
+ 30C35A0F13C51E5E0019EFCA /* Facebook.m */,
+ 30C35A1013C51E5E0019EFCA /* facebook_ios_sdk_Prefix.pch */,
+ 30C35A1113C51E5E0019EFCA /* FBConnect.h */,
+ 30C35A1213C51E5E0019EFCA /* FBDialog.bundle */,
+ 30C35A1313C51E5E0019EFCA /* FBDialog.h */,
+ 30C35A1413C51E5E0019EFCA /* FBDialog.m */,
+ 30C35A1513C51E5E0019EFCA /* FBLoginDialog.h */,
+ 30C35A1613C51E5E0019EFCA /* FBLoginDialog.m */,
+ 30C35A1713C51E5E0019EFCA /* FBRequest.h */,
+ 30C35A1813C51E5E0019EFCA /* FBRequest.m */,
+ );
+ path = FB_src;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 30C359B813C51E060019EFCA /* PhoneGapFacebookConnect */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 30C35A0513C51E060019EFCA /* Build configuration list for PBXNativeTarget "PhoneGapFacebookConnect" */;
+ buildPhases = (
+ 30C359B213C51E060019EFCA /* Sources */,
+ 30C359B313C51E060019EFCA /* Frameworks */,
+ 30C359B413C51E060019EFCA /* Resources */,
+ 30C359B513C51E060019EFCA /* Sources */,
+ 30C359B613C51E060019EFCA /* Frameworks */,
+ 30C359B713C51E060019EFCA /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = PhoneGapFacebookConnect;
+ productName = PhoneGapFacebookConnect;
+ productReference = 30C359B913C51E060019EFCA /* PhoneGapFacebookConnect.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 30C359AD13C51E060019EFCA /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 30C359B013C51E060019EFCA /* Build configuration list for PBXProject "PhoneGapFacebookConnect" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ es,
+ );
+ mainGroup = 30C359AB13C51E060019EFCA;
+ productRefGroup = 30C359BA13C51E060019EFCA /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 30C359B813C51E060019EFCA /* PhoneGapFacebookConnect */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 30C359B413C51E060019EFCA /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 30C359DC13C51E060019EFCA /* InfoPlist.strings in Resources */,
+ 30C359E613C51E060019EFCA /* Localizable.strings in Resources */,
+ 30C359EA13C51E060019EFCA /* Localizable.strings in Resources */,
+ 30C359ED13C51E060019EFCA /* icon.png in Resources */,
+ 30C359EF13C51E060019EFCA /* icon@2x.png in Resources */,
+ 30C359F113C51E060019EFCA /* icon-72.png in Resources */,
+ 30C359F413C51E060019EFCA /* Default.png in Resources */,
+ 30C359F613C51E060019EFCA /* Default@2x.png in Resources */,
+ 30C359F813C51E060019EFCA /* Default~ipad.png in Resources */,
+ 30C359FA13C51E060019EFCA /* Capture.bundle in Resources */,
+ 30C359FC13C51E060019EFCA /* PhoneGap.plist in Resources */,
+ 30C35A0913C51E290019EFCA /* www in Resources */,
+ 30C35A1B13C51E5E0019EFCA /* FBDialog.bundle in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 30C359B713C51E060019EFCA /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/bash;
+ shellScript = "\n\t\t\t\t\t\t\t\tif [ ! -d \"$PROJECT_DIR/www\" ] ; then\n\t\t\t\t\t\t\t\t\tcp -R /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework/www \"$PROJECT_DIR\"\n\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\t\t# detect www folder reference in project, if missing, print warning\n\t\t\t\t\t\t\t\tgrep \"{isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = \\\"<group>\\\"; };\" \"$PROJECT_DIR/$PROJECT_NAME.xcodeproj/project.pbxproj\"\n\t\t\t\t\t\t\t\trc=$? \n\t\t\t\t\t\t\t\tif [ $rc != 0 ] ; then\n\t\t\t\t\t\t\t\techo -e \"warning: Missing - Add $PROJECT_DIR/www as a folder reference in your project. Just drag and drop the folder into your project, in Xcode 4.\" 1>&2\n\t\t\t\t\t\t\t\tfi\t\t\t\t\t\t\t";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 30C359B213C51E060019EFCA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 30C359DF13C51E060019EFCA /* main.m in Sources */,
+ 30C35A0013C51E060019EFCA /* AppDelegate.m in Sources */,
+ 30C35A1913C51E5E0019EFCA /* FacebookConnectPlugin.m in Sources */,
+ 30C35A1A13C51E5E0019EFCA /* Facebook.m in Sources */,
+ 30C35A1C13C51E5E0019EFCA /* FBDialog.m in Sources */,
+ 30C35A1D13C51E5E0019EFCA /* FBLoginDialog.m in Sources */,
+ 30C35A1E13C51E5E0019EFCA /* FBRequest.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 30C359B513C51E060019EFCA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 30C359DA13C51E060019EFCA /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 30C359DB13C51E060019EFCA /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ 30C359E413C51E060019EFCA /* Localizable.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 30C359E513C51E060019EFCA /* en */,
+ );
+ name = Localizable.strings;
+ sourceTree = "<group>";
+ };
+ 30C359E813C51E060019EFCA /* Localizable.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 30C359E913C51E060019EFCA /* es */,
+ );
+ name = Localizable.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 30C35A0313C51E060019EFCA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.1;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 30C35A0413C51E060019EFCA /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.1;
+ SDKROOT = iphoneos;
+ };
+ name = Release;
+ };
+ 30C35A0613C51E060019EFCA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = YES;
+ COPY_PHASE_STRIP = NO;
+ FRAMEWORK_SEARCH_PATHS = /Users/Shared/PhoneGap/Frameworks;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "PhoneGapFacebookConnect/PhoneGapFacebookConnect-Prefix.pch";
+ GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES";
+ INFOPLIST_FILE = "PhoneGapFacebookConnect/PhoneGapFacebookConnect-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 30C35A0713C51E060019EFCA /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = YES;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ FRAMEWORK_SEARCH_PATHS = /Users/Shared/PhoneGap/Frameworks;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "PhoneGapFacebookConnect/PhoneGapFacebookConnect-Prefix.pch";
+ GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES";
+ INFOPLIST_FILE = "PhoneGapFacebookConnect/PhoneGapFacebookConnect-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ VALIDATE_PRODUCT = YES;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 30C359B013C51E060019EFCA /* Build configuration list for PBXProject "PhoneGapFacebookConnect" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 30C35A0313C51E060019EFCA /* Debug */,
+ 30C35A0413C51E060019EFCA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 30C35A0513C51E060019EFCA /* Build configuration list for PBXNativeTarget "PhoneGapFacebookConnect" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 30C35A0613C51E060019EFCA /* Debug */,
+ 30C35A0713C51E060019EFCA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 30C359AD13C51E060019EFCA /* Project object */;
+}
View
29 example/iOS/PhoneGapFacebookConnect/Classes/AppDelegate.h
@@ -0,0 +1,29 @@
+//
+// AppDelegate.h
+// PhoneGapFacebookConnect
+//
+// Created by shazron on 11-07-06.
+// Copyright __MyCompanyName__ 2011. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#ifdef PHONEGAP_FRAMEWORK
+ #import <PhoneGap/PhoneGapDelegate.h>
+#else
+ #import "PhoneGapDelegate.h"
+#endif
+
+@interface AppDelegate : PhoneGapDelegate {
+
+ NSString* invokeString;
+}
+
+// invoke string is passed to your app on launch, this is only valid if you
+// edit PhoneGapFacebookConnect.plist to add a protocol
+// a simple tutorial can be found here :
+// http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
+
+@property (copy) NSString* invokeString;
+
+@end
+
View
111 example/iOS/PhoneGapFacebookConnect/Classes/AppDelegate.m
@@ -0,0 +1,111 @@
+//
+// AppDelegate.m
+// PhoneGapFacebookConnect
+//
+// Created by shazron on 11-07-06.
+// Copyright __MyCompanyName__ 2011. All rights reserved.
+//
+
+#import "AppDelegate.h"
+#ifdef PHONEGAP_FRAMEWORK
+ #import <PhoneGap/PhoneGapViewController.h>
+#else
+ #import "PhoneGapViewController.h"
+#endif
+
+@implementation AppDelegate
+
+@synthesize invokeString;
+
+- (id) init
+{
+ /** If you need to do any extra app-specific initialization, you can do it here
+ * -jm
+ **/
+ return [super init];
+}
+
+/**
+ * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
+ */
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+
+ NSArray *keyArray = [launchOptions allKeys];
+ if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil)
+ {
+ NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]];
+ self.invokeString = [url absoluteString];
+ NSLog(@"PhoneGapFacebookConnect launchOptions = %@",url);
+ }
+
+ return [super application:application didFinishLaunchingWithOptions:launchOptions];
+}
+
+// this happens while we are running ( in the background, or from within our own app )
+// only valid if PhoneGapFacebookConnect.plist specifies a protocol to handle
+- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
+{
+ // must call super so all plugins will get the notification
+ return [super application:application handleOpenURL:url];
+}
+
+-(id) getCommandInstance:(NSString*)className
+{
+ /** You can catch your own commands here, if you wanted to extend the gap: protocol, or add your
+ * own app specific protocol to it. -jm
+ **/
+ return [super getCommandInstance:className];
+}
+
+/**
+ Called when the webview finishes loading. This stops the activity view and closes the imageview
+ */
+- (void)webViewDidFinishLoad:(UIWebView *)theWebView
+{
+ // only valid if PhoneGapFacebookConnect.plist specifies a protocol to handle
+ if(self.invokeString)
+ {
+ // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
+ NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
+ [theWebView stringByEvaluatingJavaScriptFromString:jsString];
+ }
+ return [ super webViewDidFinishLoad:theWebView ];
+}
+
+- (void)webViewDidStartLoad:(UIWebView *)theWebView
+{
+ return [ super webViewDidStartLoad:theWebView ];
+}
+
+/**
+ * Fail Loading With Error
+ * Error - If the webpage failed to load display an error with the reason.
+ */
+- (void)webView:(UIWebView *)theWebView didFailLoadWithError:(NSError *)error
+{
+ return [ super webView:theWebView didFailLoadWithError:error ];
+}
+
+/**
+ * Start Loading Request
+ * This is where most of the magic happens... We take the request(s) and process the response.
+ * From here we can re direct links and other protocalls to different internal methods.
+ */
+- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
+{
+ return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
+}
+
+
+- (BOOL) execute:(InvokedUrlCommand*)command
+{
+ return [ super execute:command];
+}
+
+- (void)dealloc
+{
+ [ super dealloc ];
+}
+
+@end
View
46 example/iOS/PhoneGapFacebookConnect/PhoneGap.plist
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>DetectPhoneNumber</key>
+ <true/>
+ <key>EnableAcceleration</key>
+ <true/>
+ <key>EnableLocation</key>
+ <false/>
+ <key>EnableViewportScale</key>
+ <false/>
+ <key>ExternalHosts</key>
+ <array/>
+ <key>Plugins</key>
+ <dict>
+ <key>com.phonegap.accelerometer</key>
+ <string>PGAccelerometer</string>
+ <key>com.phonegap.camera</key>
+ <string>PGCamera</string>
+ <key>com.phonegap.connection</key>
+ <string>PGConnection</string>
+ <key>com.phonegap.contacts</key>
+ <string>PGContacts</string>
+ <key>com.phonegap.debugconsole</key>
+ <string>PGDebugConsole</string>
+ <key>com.phonegap.file</key>
+ <string>PGFile</string>
+ <key>com.phonegap.filetransfer</key>
+ <string>PGFileTransfer</string>
+ <key>com.phonegap.geolocation</key>
+ <string>PGLocation</string>
+ <key>com.phonegap.media</key>
+ <string>PGSound</string>
+ <key>com.phonegap.mediacapture</key>
+ <string>PGCapture</string>
+ <key>com.phonegap.notification</key>
+ <string>PGNotification</string>
+ <key>com.facebook.phonegap.Connect</key>
+ <string>FacebookConnectPlugin</string>
+
+ </dict>
+ <key>TopActivityIndicator</key>
+ <string>gray</string>
+</dict>
+</plist>
View
60 example/iOS/PhoneGapFacebookConnect/PhoneGapFacebookConnect-Info.plist
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string>icon.png</string>
+ <key>CFBundleIconFiles</key>
+ <array>
+ <string>icon.png</string>
+ <string>icon@2x.png</string>
+ <string>icon-72.png</string>
+ </array>
+ <key>CFBundleIdentifier</key>
+ <string>ca.nitobee.PhoneGapFacebookConnect</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string></string>
+ <key>NSMainNibFile~ipad</key>
+ <string></string>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>ca.nitobee.PhoneGapFacebookConnect.login</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>fb188240441228254</string>
+ </array>
+ </dict>
+ </array>
+</dict>
+</plist>
View
8 example/iOS/PhoneGapFacebookConnect/PhoneGapFacebookConnect-Prefix.pch
@@ -0,0 +1,8 @@
+//
+// Prefix header for all source files of the 'PhoneGapFacebookConnect' target in the 'PhoneGapFacebookConnect' project
+//
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
View
27 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBConnect.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "Facebook.h"
+#include "FBDialog.h"
+#include "FBLoginDialog.h"
+#include "FBRequest.h"
+
+#ifdef PHONEGAP_FRAMEWORK
+ #import <PhoneGap/SBJSON.h>
+#else
+ #import "SBJSON.h"
+#endif
View
BIN example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.bundle/images/close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN ...ple/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.bundle/images/fbicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
167 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+@protocol FBDialogDelegate;
+
+/**
+ * Do not use this interface directly, instead, use dialog in Facebook.h
+ *
+ * Facebook dialog interface for start the facebook webView UIServer Dialog.
+ */
+
+@interface FBDialog : UIView <UIWebViewDelegate> {
+ id<FBDialogDelegate> _delegate;
+ NSMutableDictionary *_params;
+ NSString * _serverURL;
+ NSURL* _loadingURL;
+ UIWebView* _webView;
+ UIActivityIndicatorView* _spinner;
+ UIImageView* _iconView;
+ UILabel* _titleLabel;
+ UIButton* _closeButton;
+ UIDeviceOrientation _orientation;
+ BOOL _showingKeyboard;
+
+ // Ensures that UI elements behind the dialog are disabled.
+ UIView* _modalBackgroundView;
+}
+
+/**
+ * The delegate.
+ */
+@property(nonatomic,assign) id<FBDialogDelegate> delegate;
+
+/**
+ * The parameters.
+ */
+@property(nonatomic, retain) NSMutableDictionary* params;
+
+/**
+ * The title that is shown in the header atop the view.
+ */
+@property(nonatomic,copy) NSString* title;
+
+- (NSString *) getStringFromUrl: (NSString*) url needle:(NSString *) needle;
+
+- (id)initWithURL: (NSString *) loadingURL
+ params: (NSMutableDictionary *) params
+ delegate: (id <FBDialogDelegate>) delegate;
+
+/**
+ * Displays the view with an animation.
+ *
+ * The view will be added to the top of the current key window.
+ */
+- (void)show;
+
+/**
+ * Displays the first page of the dialog.
+ *
+ * Do not ever call this directly. It is intended to be overriden by subclasses.
+ */
+- (void)load;
+
+/**
+ * Displays a URL in the dialog.
+ */
+- (void)loadURL:(NSString*)url
+ get:(NSDictionary*)getParams;
+
+/**
+ * Hides the view and notifies delegates of success or cancellation.
+ */
+- (void)dismissWithSuccess:(BOOL)success animated:(BOOL)animated;
+
+/**
+ * Hides the view and notifies delegates of an error.
+ */
+- (void)dismissWithError:(NSError*)error animated:(BOOL)animated;
+
+/**
+ * Subclasses may override to perform actions just prior to showing the dialog.
+ */
+- (void)dialogWillAppear;
+
+/**
+ * Subclasses may override to perform actions just after the dialog is hidden.
+ */
+- (void)dialogWillDisappear;
+
+/**
+ * Subclasses should override to process data returned from the server in a 'fbconnect' url.
+ *
+ * Implementations must call dismissWithSuccess:YES at some point to hide the dialog.
+ */
+- (void)dialogDidSucceed:(NSURL *)url;
+
+/**
+ * Subclasses should override to process data returned from the server in a 'fbconnect' url.
+ *
+ * Implementations must call dismissWithSuccess:YES at some point to hide the dialog.
+ */
+- (void)dialogDidCancel:(NSURL *)url;
+@end
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+ *Your application should implement this delegate
+ */
+@protocol FBDialogDelegate <NSObject>
+
+@optional
+
+/**
+ * Called when the dialog succeeds and is about to be dismissed.
+ */
+- (void)dialogDidComplete:(FBDialog *)dialog;
+
+/**
+ * Called when the dialog succeeds with a returning url.
+ */
+- (void)dialogCompleteWithUrl:(NSURL *)url;
+
+/**
+ * Called when the dialog get canceled by the user.
+ */
+- (void)dialogDidNotCompleteWithUrl:(NSURL *)url;
+
+/**
+ * Called when the dialog is cancelled and is about to be dismissed.
+ */
+- (void)dialogDidNotComplete:(FBDialog *)dialog;
+
+/**
+ * Called when dialog failed to load due to an error.
+ */
+- (void)dialog:(FBDialog*)dialog didFailWithError:(NSError *)error;
+
+/**
+ * Asks if a link touched by a user should be opened in an external browser.
+ *
+ * If a user touches a link, the default behavior is to open the link in the Safari browser,
+ * which will cause your app to quit. You may want to prevent this from happening, open the link
+ * in your own internal browser, or perhaps warn the user that they are about to leave your app.
+ * If so, implement this method on your delegate and return NO. If you warn the user, you
+ * should hold onto the URL and once you have received their acknowledgement open the URL yourself
+ * using [[UIApplication sharedApplication] openURL:].
+ */
+- (BOOL)dialog:(FBDialog*)dialog shouldOpenURLInExternalBrowser:(NSURL *)url;
+
+@end
View
656 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBDialog.m
@@ -0,0 +1,656 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+
+#import "FBDialog.h"
+#import "Facebook.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// global
+
+static NSString* kDefaultTitle = @"Connect to Facebook";
+
+static CGFloat kFacebookBlue[4] = {0.42578125, 0.515625, 0.703125, 1.0};
+static CGFloat kBorderGray[4] = {0.3, 0.3, 0.3, 0.8};
+static CGFloat kBorderBlack[4] = {0.3, 0.3, 0.3, 1};
+static CGFloat kBorderBlue[4] = {0.23, 0.35, 0.6, 1.0};
+
+static CGFloat kTransitionDuration = 0.3;
+
+static CGFloat kTitleMarginX = 8;
+static CGFloat kTitleMarginY = 4;
+static CGFloat kPadding = 10;
+static CGFloat kBorderWidth = 10;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL FBIsDeviceIPad() {
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ return YES;
+ }
+#endif
+ return NO;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+@implementation FBDialog
+
+@synthesize delegate = _delegate,
+ params = _params;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// private
+
+- (void)addRoundedRectToPath:(CGContextRef)context rect:(CGRect)rect radius:(float)radius {
+ CGContextBeginPath(context);
+ CGContextSaveGState(context);
+
+ if (radius == 0) {
+ CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect));
+ CGContextAddRect(context, rect);
+ } else {
+ rect = CGRectOffset(CGRectInset(rect, 0.5, 0.5), 0.5, 0.5);
+ CGContextTranslateCTM(context, CGRectGetMinX(rect)-0.5, CGRectGetMinY(rect)-0.5);
+ CGContextScaleCTM(context, radius, radius);
+ float fw = CGRectGetWidth(rect) / radius;
+ float fh = CGRectGetHeight(rect) / radius;
+
+ CGContextMoveToPoint(context, fw, fh/2);
+ CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);
+ CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);
+ CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);
+ CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1);
+ }
+
+ CGContextClosePath(context);
+ CGContextRestoreGState(context);
+}
+
+- (void)drawRect:(CGRect)rect fill:(const CGFloat*)fillColors radius:(CGFloat)radius {
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+
+ if (fillColors) {
+ CGContextSaveGState(context);
+ CGContextSetFillColor(context, fillColors);
+ if (radius) {
+ [self addRoundedRectToPath:context rect:rect radius:radius];
+ CGContextFillPath(context);
+ } else {
+ CGContextFillRect(context, rect);
+ }
+ CGContextRestoreGState(context);
+ }
+
+ CGColorSpaceRelease(space);
+}
+
+- (void)strokeLines:(CGRect)rect stroke:(const CGFloat*)strokeColor {
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+
+ CGContextSaveGState(context);
+ CGContextSetStrokeColorSpace(context, space);
+ CGContextSetStrokeColor(context, strokeColor);
+ CGContextSetLineWidth(context, 1.0);
+
+ {
+ CGPoint points[] = {{rect.origin.x+0.5, rect.origin.y-0.5},
+ {rect.origin.x+rect.size.width, rect.origin.y-0.5}};
+ CGContextStrokeLineSegments(context, points, 2);
+ }
+ {
+ CGPoint points[] = {{rect.origin.x+0.5, rect.origin.y+rect.size.height-0.5},
+ {rect.origin.x+rect.size.width-0.5, rect.origin.y+rect.size.height-0.5}};
+ CGContextStrokeLineSegments(context, points, 2);
+ }
+ {
+ CGPoint points[] = {{rect.origin.x+rect.size.width-0.5, rect.origin.y},
+ {rect.origin.x+rect.size.width-0.5, rect.origin.y+rect.size.height}};
+ CGContextStrokeLineSegments(context, points, 2);
+ }
+ {
+ CGPoint points[] = {{rect.origin.x+0.5, rect.origin.y},
+ {rect.origin.x+0.5, rect.origin.y+rect.size.height}};
+ CGContextStrokeLineSegments(context, points, 2);
+ }
+
+ CGContextRestoreGState(context);
+
+ CGColorSpaceRelease(space);
+}
+
+- (BOOL)shouldRotateToOrientation:(UIDeviceOrientation)orientation {
+ if (orientation == _orientation) {
+ return NO;
+ } else {
+ return orientation == UIDeviceOrientationLandscapeLeft
+ || orientation == UIDeviceOrientationLandscapeRight
+ || orientation == UIDeviceOrientationPortrait
+ || orientation == UIDeviceOrientationPortraitUpsideDown;
+ }
+}
+
+- (CGAffineTransform)transformForOrientation {
+ UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
+ if (orientation == UIInterfaceOrientationLandscapeLeft) {
+ return CGAffineTransformMakeRotation(M_PI*1.5);
+ } else if (orientation == UIInterfaceOrientationLandscapeRight) {
+ return CGAffineTransformMakeRotation(M_PI/2);
+ } else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
+ return CGAffineTransformMakeRotation(-M_PI);
+ } else {
+ return CGAffineTransformIdentity;
+ }
+}
+
+- (void)sizeToFitOrientation:(BOOL)transform {
+ if (transform) {
+ self.transform = CGAffineTransformIdentity;
+ }
+
+ CGRect frame = [UIScreen mainScreen].applicationFrame;
+ CGPoint center = CGPointMake(
+ frame.origin.x + ceil(frame.size.width/2),
+ frame.origin.y + ceil(frame.size.height/2));
+
+ CGFloat scale_factor = 1.0f;
+ if (FBIsDeviceIPad()) {
+ // On the iPad the dialog's dimensions should only be 60% of the screen's
+ scale_factor = 0.6f;
+ }
+
+ CGFloat width = floor(scale_factor * frame.size.width) - kPadding * 2;
+ CGFloat height = floor(scale_factor * frame.size.height) - kPadding * 2;
+
+ _orientation = [UIApplication sharedApplication].statusBarOrientation;
+ if (UIInterfaceOrientationIsLandscape(_orientation)) {
+ self.frame = CGRectMake(kPadding, kPadding, height, width);
+ } else {
+ self.frame = CGRectMake(kPadding, kPadding, width, height);
+ }
+ self.center = center;
+
+ if (transform) {
+ self.transform = [self transformForOrientation];
+ }
+}
+
+- (void)updateWebOrientation {
+ UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
+ if (UIInterfaceOrientationIsLandscape(orientation)) {
+ [_webView stringByEvaluatingJavaScriptFromString:
+ @"document.body.setAttribute('orientation', 90);"];
+ } else {
+ [_webView stringByEvaluatingJavaScriptFromString:
+ @"document.body.removeAttribute('orientation');"];
+ }
+}
+
+- (void)bounce1AnimationStopped {
+ [UIView beginAnimations:nil context:nil];
+ [UIView setAnimationDuration:kTransitionDuration/2];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(bounce2AnimationStopped)];
+ self.transform = CGAffineTransformScale([self transformForOrientation], 0.9, 0.9);
+ [UIView commitAnimations];
+}
+
+- (void)bounce2AnimationStopped {
+ [UIView beginAnimations:nil context:nil];
+ [UIView setAnimationDuration:kTransitionDuration/2];
+ self.transform = [self transformForOrientation];
+ [UIView commitAnimations];
+}
+
+- (NSURL*)generateURL:(NSString*)baseURL params:(NSDictionary*)params {
+ if (params) {
+ NSMutableArray* pairs = [NSMutableArray array];
+ for (NSString* key in params.keyEnumerator) {
+ NSString* value = [params objectForKey:key];
+ NSString* escaped_value = (NSString *)CFURLCreateStringByAddingPercentEscapes(
+ NULL, /* allocator */
+ (CFStringRef)value,
+ NULL, /* charactersToLeaveUnescaped */
+ (CFStringRef)@"!*'();:@&=+$,/?%#[]",
+ kCFStringEncodingUTF8);
+
+ [pairs addObject:[NSString stringWithFormat:@"%@=%@", key, escaped_value]];
+ [escaped_value release];
+ }
+
+ NSString* query = [pairs componentsJoinedByString:@"&"];
+ NSString* url = [NSString stringWithFormat:@"%@?%@", baseURL, query];
+ return [NSURL URLWithString:url];
+ } else {
+ return [NSURL URLWithString:baseURL];
+ }
+}
+
+- (void)addObservers {
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(deviceOrientationDidChange:)
+ name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillShow:) name:@"UIKeyboardWillShowNotification" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillHide:) name:@"UIKeyboardWillHideNotification" object:nil];
+}
+
+- (void)removeObservers {
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:@"UIKeyboardWillShowNotification" object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:@"UIKeyboardWillHideNotification" object:nil];
+}
+
+- (void)postDismissCleanup {
+ [self removeObservers];
+ [self removeFromSuperview];
+ [_modalBackgroundView removeFromSuperview];
+}
+
+- (void)dismiss:(BOOL)animated {
+ [self dialogWillDisappear];
+
+ [_loadingURL release];
+ _loadingURL = nil;
+
+ if (animated) {
+ [UIView beginAnimations:nil context:nil];
+ [UIView setAnimationDuration:kTransitionDuration];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(postDismissCleanup)];
+ self.alpha = 0;
+ [UIView commitAnimations];
+ } else {
+ [self postDismissCleanup];
+ }
+}
+
+- (void)cancel {
+ [self dialogDidCancel:nil];
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// NSObject
+
+- (id)init {
+ if (self = [super initWithFrame:CGRectZero]) {
+ _delegate = nil;
+ _loadingURL = nil;
+ _orientation = UIDeviceOrientationUnknown;
+ _showingKeyboard = NO;
+
+ self.backgroundColor = [UIColor clearColor];
+ self.autoresizesSubviews = YES;
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ self.contentMode = UIViewContentModeRedraw;
+
+ UIImage* iconImage = [UIImage imageNamed:@"FBDialog.bundle/images/fbicon.png"];
+ UIImage* closeImage = [UIImage imageNamed:@"FBDialog.bundle/images/close.png"];
+
+ _iconView = [[UIImageView alloc] initWithImage:iconImage];
+ [self addSubview:_iconView];
+
+ UIColor* color = [UIColor colorWithRed:167.0/255 green:184.0/255 blue:216.0/255 alpha:1];
+ _closeButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
+ [_closeButton setImage:closeImage forState:UIControlStateNormal];
+ [_closeButton setTitleColor:color forState:UIControlStateNormal];
+ [_closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
+ [_closeButton addTarget:self action:@selector(cancel)
+ forControlEvents:UIControlEventTouchUpInside];
+
+ // To be compatible with OS 2.x
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_2_2
+ _closeButton.font = [UIFont boldSystemFontOfSize:12];
+ #else
+ _closeButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
+ #endif
+
+ _closeButton.showsTouchWhenHighlighted = YES;
+ _closeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin
+ | UIViewAutoresizingFlexibleBottomMargin;
+ [self addSubview:_closeButton];
+
+ CGFloat titleLabelFontSize = (FBIsDeviceIPad() ? 18 : 14);
+ _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ _titleLabel.text = kDefaultTitle;
+ _titleLabel.backgroundColor = [UIColor clearColor];
+ _titleLabel.textColor = [UIColor whiteColor];
+ _titleLabel.font = [UIFont boldSystemFontOfSize:titleLabelFontSize];
+ _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin
+ | UIViewAutoresizingFlexibleBottomMargin;
+ [self addSubview:_titleLabel];
+
+ _webView = [[UIWebView alloc] initWithFrame:CGRectMake(kPadding, kPadding, 480, 480)];
+ _webView.delegate = self;
+ _webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ [self addSubview:_webView];
+
+ _spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
+ UIActivityIndicatorViewStyleWhiteLarge];
+ _spinner.autoresizingMask =
+ UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
+ | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
+ [self addSubview:_spinner];
+ _modalBackgroundView = [[UIView alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ _webView.delegate = nil;
+ [_webView release];
+ [_params release];
+ [_serverURL release];
+ [_spinner release];
+ [_titleLabel release];
+ [_iconView release];
+ [_closeButton release];
+ [_loadingURL release];
+ [_modalBackgroundView release];
+ [super dealloc];
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// UIView
+
+- (void)drawRect:(CGRect)rect {
+ CGRect grayRect = CGRectOffset(rect, -0.5, -0.5);
+ [self drawRect:grayRect fill:kBorderGray radius:10];
+
+ CGRect headerRect = CGRectMake(
+ ceil(rect.origin.x + kBorderWidth), ceil(rect.origin.y + kBorderWidth),
+ rect.size.width - kBorderWidth*2, _titleLabel.frame.size.height);
+ [self drawRect:headerRect fill:kFacebookBlue radius:0];
+ [self strokeLines:headerRect stroke:kBorderBlue];
+
+ CGRect webRect = CGRectMake(
+ ceil(rect.origin.x + kBorderWidth), headerRect.origin.y + headerRect.size.height,
+ rect.size.width - kBorderWidth*2, _webView.frame.size.height+1);
+ [self strokeLines:webRect stroke:kBorderBlack];
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// UIWebViewDelegate
+
+- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
+ navigationType:(UIWebViewNavigationType)navigationType {
+ NSURL* url = request.URL;
+
+ if ([url.scheme isEqualToString:@"fbconnect"]) {
+ if ([[url.resourceSpecifier substringToIndex:8] isEqualToString:@"//cancel"]) {
+ NSString * errorCode = [self getStringFromUrl:[url absoluteString] needle:@"error_code="];
+ NSString * errorStr = [self getStringFromUrl:[url absoluteString] needle:@"error_msg="];
+ if (errorCode) {
+ NSDictionary * errorData = [NSDictionary dictionaryWithObject:errorStr forKey:@"error_msg"];
+ NSError * error = [NSError errorWithDomain:@"facebookErrDomain"
+ code:[errorCode intValue]
+ userInfo:errorData];
+ [self dismissWithError:error animated:YES];
+ } else {
+ [self dialogDidCancel:url];
+ }
+ } else {
+ [self dialogDidSucceed:url];
+ }
+ return NO;
+ } else if ([_loadingURL isEqual:url]) {
+ return YES;
+ } else if (navigationType == UIWebViewNavigationTypeLinkClicked) {
+ if ([_delegate respondsToSelector:@selector(dialog:shouldOpenURLInExternalBrowser:)]) {
+ if (![_delegate dialog:self shouldOpenURLInExternalBrowser:url]) {
+ return NO;
+ }
+ }
+
+ [[UIApplication sharedApplication] openURL:request.URL];
+ return NO;
+ } else {
+ return YES;
+ }
+}
+
+- (void)webViewDidFinishLoad:(UIWebView *)webView {
+ [_spinner stopAnimating];
+ _spinner.hidden = YES;
+
+ self.title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
+ [self updateWebOrientation];
+}
+
+- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
+ // 102 == WebKitErrorFrameLoadInterruptedByPolicyChange
+ if (!([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102)) {
+ [self dismissWithError:error animated:YES];
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// UIDeviceOrientationDidChangeNotification
+
+- (void)deviceOrientationDidChange:(void*)object {
+ UIDeviceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
+ if (!_showingKeyboard && [self shouldRotateToOrientation:orientation]) {
+ [self updateWebOrientation];
+
+ CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
+ [UIView beginAnimations:nil context:nil];
+ [UIView setAnimationDuration:duration];
+ [self sizeToFitOrientation:YES];
+ [UIView commitAnimations];
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// UIKeyboardNotifications
+
+- (void)keyboardWillShow:(NSNotification*)notification {
+
+ _showingKeyboard = YES;
+
+ if (FBIsDeviceIPad()) {
+ // On the iPad the screen is large enough that we don't need to
+ // resize the dialog to accomodate the keyboard popping up
+ return;
+ }
+
+ UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
+ if (UIInterfaceOrientationIsLandscape(orientation)) {
+ _webView.frame = CGRectInset(_webView.frame,
+ -(kPadding + kBorderWidth),
+ -(kPadding + kBorderWidth) - _titleLabel.frame.size.height);
+ }
+}
+
+- (void)keyboardWillHide:(NSNotification*)notification {
+ _showingKeyboard = NO;
+
+ if (FBIsDeviceIPad()) {
+ return;
+ }
+ UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
+ if (UIInterfaceOrientationIsLandscape(orientation)) {
+ _webView.frame = CGRectInset(_webView.frame,
+ kPadding + kBorderWidth,
+ kPadding + kBorderWidth + _titleLabel.frame.size.height);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+// public
+
+/**
+ * Find a specific parameter from the url
+ */
+- (NSString *) getStringFromUrl: (NSString*) url needle:(NSString *) needle {
+ NSString * str = nil;
+ NSRange start = [url rangeOfString:needle];
+ if (start.location != NSNotFound) {
+ NSRange end = [[url substringFromIndex:start.location+start.length] rangeOfString:@"&"];
+ NSUInteger offset = start.location+start.length;
+ str = end.location == NSNotFound
+ ? [url substringFromIndex:offset]
+ : [url substringWithRange:NSMakeRange(offset, end.location)];
+ str = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ }
+
+ return str;
+}
+
+- (id)initWithURL: (NSString *) serverURL
+ params: (NSMutableDictionary *) params
+ delegate: (id <FBDialogDelegate>) delegate {
+
+ self = [self init];
+ _serverURL = [serverURL retain];
+ _params = [params retain];
+ _delegate = delegate;
+
+ return self;
+}
+
+- (NSString*)title {
+ return _titleLabel.text;
+}
+
+- (void)setTitle:(NSString*)title {
+ _titleLabel.text = title;
+}
+
+- (void)load {
+ [self loadURL:_serverURL get:_params];
+}
+
+- (void)loadURL:(NSString*)url get:(NSDictionary*)getParams {
+
+ [_loadingURL release];
+ _loadingURL = [[self generateURL:url params:getParams] retain];
+ NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:_loadingURL];
+
+ [_webView loadRequest:request];
+}
+
+- (void)show {
+ [self load];
+ [self sizeToFitOrientation:NO];
+
+ CGFloat innerWidth = self.frame.size.width - (kBorderWidth+1)*2;
+ [_iconView sizeToFit];
+ [_titleLabel sizeToFit];
+ [_closeButton sizeToFit];
+
+ _titleLabel.frame = CGRectMake(
+ kBorderWidth + kTitleMarginX + _iconView.frame.size.width + kTitleMarginX,
+ kBorderWidth,
+ innerWidth - (_titleLabel.frame.size.height + _iconView.frame.size.width + kTitleMarginX*2),
+ _titleLabel.frame.size.height + kTitleMarginY*2);
+
+ _iconView.frame = CGRectMake(
+ kBorderWidth + kTitleMarginX,
+ kBorderWidth + floor(_titleLabel.frame.size.height/2 - _iconView.frame.size.height/2),
+ _iconView.frame.size.width,
+ _iconView.frame.size.height);
+
+ _closeButton.frame = CGRectMake(
+ self.frame.size.width - (_titleLabel.frame.size.height + kBorderWidth),
+ kBorderWidth,
+ _titleLabel.frame.size.height,
+ _titleLabel.frame.size.height);
+
+ _webView.frame = CGRectMake(
+ kBorderWidth+1,
+ kBorderWidth + _titleLabel.frame.size.height,
+ innerWidth,
+ self.frame.size.height - (_titleLabel.frame.size.height + 1 + kBorderWidth*2));
+
+ [_spinner sizeToFit];
+ [_spinner startAnimating];
+ _spinner.center = _webView.center;
+
+ UIWindow* window = [UIApplication sharedApplication].keyWindow;
+ if (!window) {
+ window = [[UIApplication sharedApplication].windows objectAtIndex:0];
+ }
+
+ _modalBackgroundView.frame = window.frame;
+ [_modalBackgroundView addSubview:self];
+ [window addSubview:_modalBackgroundView];
+
+ [window addSubview:self];
+
+ [self dialogWillAppear];
+
+ self.transform = CGAffineTransformScale([self transformForOrientation], 0.001, 0.001);
+ [UIView beginAnimations:nil context:nil];
+ [UIView setAnimationDuration:kTransitionDuration/1.5];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
+ self.transform = CGAffineTransformScale([self transformForOrientation], 1.1, 1.1);
+ [UIView commitAnimations];
+
+ [self addObservers];
+}
+
+- (void)dismissWithSuccess:(BOOL)success animated:(BOOL)animated {
+ if (success) {
+ if ([_delegate respondsToSelector:@selector(dialogDidComplete:)]) {
+ [_delegate dialogDidComplete:self];
+ }
+ } else {
+ if ([_delegate respondsToSelector:@selector(dialogDidNotComplete:)]) {
+ [_delegate dialogDidNotComplete:self];
+ }
+ }
+
+ [self dismiss:animated];
+}
+
+- (void)dismissWithError:(NSError*)error animated:(BOOL)animated {
+ if ([_delegate respondsToSelector:@selector(dialog:didFailWithError:)]) {
+ [_delegate dialog:self didFailWithError:error];
+ }
+
+ [self dismiss:animated];
+}
+
+- (void)dialogWillAppear {
+}
+
+- (void)dialogWillDisappear {
+}
+
+- (void)dialogDidSucceed:(NSURL *)url {
+
+ if ([_delegate respondsToSelector:@selector(dialogCompleteWithUrl:)]) {
+ [_delegate dialogCompleteWithUrl:url];
+ }
+ [self dismissWithSuccess:YES animated:YES];
+}
+
+- (void)dialogDidCancel:(NSURL *)url {
+ if ([_delegate respondsToSelector:@selector(dialogDidNotCompleteWithUrl:)]) {
+ [_delegate dialogDidNotCompleteWithUrl:url];
+ }
+ [self dismissWithSuccess:NO animated:YES];
+}
+
+@end
View
48 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBLoginDialog.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#import "FBDialog.h"
+
+@protocol FBLoginDialogDelegate;
+
+/**
+ * Do not use this interface directly, instead, use authorize in Facebook.h
+ *
+ * Facebook Login Dialog interface for start the facebook webView login dialog.
+ * It start pop-ups prompting for credentials and permissions.
+ */
+
+@interface FBLoginDialog : FBDialog {
+ id<FBLoginDialogDelegate> _loginDelegate;
+}
+
+-(id) initWithURL:(NSString *) loginURL
+ loginParams:(NSMutableDictionary *) params
+ delegate:(id <FBLoginDialogDelegate>) delegate;
+@end
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+@protocol FBLoginDialogDelegate <NSObject>
+
+- (void)fbDialogLogin:(NSString*)token expirationDate:(NSDate*)expirationDate;
+
+- (void)fbDialogNotLogin:(BOOL)cancelled;
+
+@end
+
+
View
94 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBLoginDialog.m
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FBDialog.h"
+#import "FBLoginDialog.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+@implementation FBLoginDialog
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// public
+
+/*
+ * initialize the FBLoginDialog with url and parameters
+ */
+- (id)initWithURL:(NSString*) loginURL
+ loginParams:(NSMutableDictionary*) params
+ delegate:(id <FBLoginDialogDelegate>) delegate{
+
+ self = [super init];
+ _serverURL = [loginURL retain];
+ _params = [params retain];
+ _loginDelegate = delegate;
+ return self;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// FBDialog
+
+/**
+ * Override FBDialog : to call when the webView Dialog did succeed
+ */
+- (void) dialogDidSucceed:(NSURL*)url {
+ NSString *q = [url absoluteString];
+ NSString *token = [self getStringFromUrl:q needle:@"access_token="];
+ NSString *expTime = [self getStringFromUrl:q needle:@"expires_in="];
+ NSDate *expirationDate =nil;
+
+ if (expTime != nil) {
+ int expVal = [expTime intValue];
+ if (expVal == 0) {
+ expirationDate = [NSDate distantFuture];
+ } else {
+ expirationDate = [NSDate dateWithTimeIntervalSinceNow:expVal];
+ }
+ }
+
+ if ((token == (NSString *) [NSNull null]) || (token.length == 0)) {
+ [self dialogDidCancel:url];
+ [self dismissWithSuccess:NO animated:YES];
+ } else {
+ if ([_loginDelegate respondsToSelector:@selector(fbDialogLogin:expirationDate:)]) {
+ [_loginDelegate fbDialogLogin:token expirationDate:expirationDate];
+ }
+ [self dismissWithSuccess:YES animated:YES];
+ }
+
+}
+
+/**
+ * Override FBDialog : to call with the login dialog get canceled
+ */
+- (void)dialogDidCancel:(NSURL *)url {
+ [self dismissWithSuccess:NO animated:YES];
+ if ([_loginDelegate respondsToSelector:@selector(fbDialogNotLogin:)]) {
+ [_loginDelegate fbDialogNotLogin:YES];
+ }
+}
+
+- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
+ if (!(([error.domain isEqualToString:@"NSURLErrorDomain"] && error.code == -999) ||
+ ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102))) {
+ [super webView:webView didFailLoadWithError:error];
+ if ([_loginDelegate respondsToSelector:@selector(fbDialogNotLogin:)]) {
+ [_loginDelegate fbDialogNotLogin:NO];
+ }
+ }
+}
+
+@end
View
116 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBRequest.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+@protocol FBRequestDelegate;
+
+/**
+ * Do not use this interface directly, instead, use method in Facebook.h
+ */
+@interface FBRequest : NSObject {
+ id<FBRequestDelegate> _delegate;
+ NSString* _url;
+ NSString* _httpMethod;
+ NSMutableDictionary* _params;
+ NSURLConnection* _connection;
+ NSMutableData* _responseText;
+}
+
+
+@property(nonatomic,assign) id<FBRequestDelegate> delegate;
+
+/**
+ * The URL which will be contacted to execute the request.
+ */
+@property(nonatomic,copy) NSString* url;
+
+/**
+ * The API method which will be called.
+ */
+@property(nonatomic,copy) NSString* httpMethod;
+
+/**
+ * The dictionary of parameters to pass to the method.
+ *
+ * These values in the dictionary will be converted to strings using the
+ * standard Objective-C object-to-string conversion facilities.
+ */
+@property(nonatomic,retain) NSMutableDictionary* params;
+@property(nonatomic,assign) NSURLConnection* connection;
+@property(nonatomic,assign) NSMutableData* responseText;
+
+
++ (NSString*)serializeURL:(NSString *)baseUrl
+ params:(NSDictionary *)params;
+
++ (NSString*)serializeURL:(NSString *)baseUrl
+ params:(NSDictionary *)params
+ httpMethod:(NSString *)httpMethod;
+
++ (FBRequest*)getRequestWithParams:(NSMutableDictionary *) params
+ httpMethod:(NSString *) httpMethod
+ delegate:(id<FBRequestDelegate>)delegate
+ requestURL:(NSString *) url;
+- (BOOL) loading;
+
+- (void) connect;
+
+@end
+
+////////////////////////////////////////////////////////////////////////////////
+
+/*
+ *Your application should implement this delegate
+ */
+@protocol FBRequestDelegate <NSObject>
+
+@optional
+
+/**
+ * Called just before the request is sent to the server.
+ */
+- (void)requestLoading:(FBRequest *)request;
+
+/**
+ * Called when the server responds and begins to send back data.
+ */
+- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response;
+
+/**
+ * Called when an error prevents the request from completing successfully.
+ */
+- (void)request:(FBRequest *)request didFailWithError:(NSError *)error;
+
+/**
+ * Called when a request returns and its response has been parsed into
+ * an object.
+ *
+ * The resulting object may be a dictionary, an array, a string, or a number,
+ * depending on thee format of the API response.
+ */
+- (void)request:(FBRequest *)request didLoad:(id)result;
+
+/**
+ * Called when a request returns a response.
+ *
+ * The result object is the raw response from the server of type NSData
+ */
+- (void)request:(FBRequest *)request didLoadRawResponse:(NSData *)data;
+
+@end
+
View
367 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/FBRequest.m
@@ -0,0 +1,367 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FBRequest.h"
+#ifdef PHONEGAP_FRAMEWORK
+ #import <PhoneGap/JSON.h>
+#else
+ #import "JSON.h"
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// global
+
+static NSString* kUserAgent = @"FacebookConnect";
+static NSString* kStringBoundary = @"3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
+static const int kGeneralErrorCode = 10000;
+
+static const NSTimeInterval kTimeoutInterval = 180.0;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+@implementation FBRequest
+
+@synthesize delegate = _delegate,
+ url = _url,
+ httpMethod = _httpMethod,
+ params = _params,
+ connection = _connection,
+ responseText = _responseText;
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+// class public
+
++ (FBRequest *)getRequestWithParams:(NSMutableDictionary *) params
+ httpMethod:(NSString *) httpMethod
+ delegate:(id<FBRequestDelegate>) delegate
+ requestURL:(NSString *) url {
+
+ FBRequest* request = [[[FBRequest alloc] init] autorelease];
+ request.delegate = delegate;
+ request.url = url;
+ request.httpMethod = httpMethod;
+ request.params = params;
+ request.connection = nil;
+ request.responseText = nil;
+
+ return request;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// private
+
++ (NSString *)serializeURL:(NSString *)baseUrl
+ params:(NSDictionary *)params {
+ return [self serializeURL:baseUrl params:params httpMethod:@"GET"];
+}
+
+/**
+ * Generate get URL
+ */
++ (NSString*)serializeURL:(NSString *)baseUrl
+ params:(NSDictionary *)params
+ httpMethod:(NSString *)httpMethod {
+
+ NSURL* parsedURL = [NSURL URLWithString:baseUrl];
+ NSString* queryPrefix = parsedURL.query ? @"&" : @"?";
+
+ NSMutableArray* pairs = [NSMutableArray array];
+ for (NSString* key in [params keyEnumerator]) {
+ if (([[params valueForKey:key] isKindOfClass:[UIImage class]])
+ ||([[params valueForKey:key] isKindOfClass:[NSData class]])) {
+ if ([httpMethod isEqualToString:@"GET"]) {
+ NSLog(@"can not use GET to upload a file");
+ }
+ continue;
+ }
+
+ NSString* escaped_value = (NSString *)CFURLCreateStringByAddingPercentEscapes(
+ NULL, /* allocator */
+ (CFStringRef)[params objectForKey:key],
+ NULL, /* charactersToLeaveUnescaped */
+ (CFStringRef)@"!*'();:@&=+$,/?%#[]",
+ kCFStringEncodingUTF8);
+
+ [pairs addObject:[NSString stringWithFormat:@"%@=%@", key, escaped_value]];
+ [escaped_value release];
+ }
+ NSString* query = [pairs componentsJoinedByString:@"&"];
+
+ return [NSString stringWithFormat:@"%@%@%@", baseUrl, queryPrefix, query];
+}
+
+/**
+ * Body append for POST method
+ */
+- (void)utfAppendBody:(NSMutableData *)body data:(NSString *)data {
+ [body appendData:[data dataUsingEncoding:NSUTF8StringEncoding]];
+}
+
+/**
+ * Generate body for POST method
+ */
+- (NSMutableData *)generatePostBody {
+ NSMutableData *body = [NSMutableData data];
+ NSString *endLine = [NSString stringWithFormat:@"\r\n--%@\r\n", kStringBoundary];
+ NSMutableDictionary *dataDictionary = [NSMutableDictionary dictionary];
+
+ [self utfAppendBody:body data:[NSString stringWithFormat:@"--%@\r\n", kStringBoundary]];
+
+ for (id key in [_params keyEnumerator]) {
+
+ if (([[_params valueForKey:key] isKindOfClass:[UIImage class]])
+ ||([[_params valueForKey:key] isKindOfClass:[NSData class]])) {
+
+ [dataDictionary setObject:[_params valueForKey:key] forKey:key];
+ continue;
+
+ }
+
+ [self utfAppendBody:body
+ data:[NSString
+ stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",
+ key]];
+ [self utfAppendBody:body data:[_params valueForKey:key]];
+
+ [self utfAppendBody:body data:endLine];
+ }
+
+ if ([dataDictionary count] > 0) {
+ for (id key in dataDictionary) {
+ NSObject *dataParam = [dataDictionary valueForKey:key];
+ if ([dataParam isKindOfClass:[UIImage class]]) {
+ NSData* imageData = UIImagePNGRepresentation((UIImage*)dataParam);
+ [self utfAppendBody:body
+ data:[NSString stringWithFormat:
+ @"Content-Disposition: form-data; filename=\"%@\"\r\n", key]];
+ [self utfAppendBody:body
+ data:[NSString stringWithString:@"Content-Type: image/png\r\n\r\n"]];
+ [body appendData:imageData];
+ } else {
+ NSAssert([dataParam isKindOfClass:[NSData class]],
+ @"dataParam must be a UIImage or NSData");
+ [self utfAppendBody:body
+ data:[NSString stringWithFormat:
+ @"Content-Disposition: form-data; filename=\"%@\"\r\n", key]];
+ [self utfAppendBody:body
+ data:[NSString stringWithString:@"Content-Type: content/unknown\r\n\r\n"]];
+ [body appendData:(NSData*)dataParam];
+ }
+ [self utfAppendBody:body data:endLine];
+
+ }
+ }
+
+ return body;
+}
+
+/**
+ * Formulate the NSError
+ */
+- (id)formError:(NSInteger)code userInfo:(NSDictionary *) errorData {
+ return [NSError errorWithDomain:@"facebookErrDomain" code:code userInfo:errorData];
+
+}
+
+/**
+ * parse the response data
+ */
+- (id)parseJsonResponse:(NSData *)data error:(NSError **)error {
+
+ NSString* responseString = [[[NSString alloc] initWithData:data
+ encoding:NSUTF8StringEncoding]
+ autorelease];
+ SBJSON *jsonParser = [[SBJSON new] autorelease];
+ if ([responseString isEqualToString:@"true"]) {
+ return [NSDictionary dictionaryWithObject:@"true" forKey:@"result"];
+ } else if ([responseString isEqualToString:@"false"]) {
+ if (error != nil) {
+ *error = [self formError:kGeneralErrorCode
+ userInfo:[NSDictionary
+ dictionaryWithObject:@"This operation can not be completed"
+ forKey:@"error_msg"]];
+ }
+ return nil;
+ }
+
+
+ id result = [jsonParser objectWithString:responseString];
+
+ if (![result isKindOfClass:[NSArray class]]) {
+ if ([result objectForKey:@"error"] != nil) {
+ if (error != nil) {
+ *error = [self formError:kGeneralErrorCode
+ userInfo:result];
+ }
+ return nil;
+ }
+
+ if ([result objectForKey:@"error_code"] != nil) {
+ if (error != nil) {
+ *error = [self formError:[[result objectForKey:@"error_code"] intValue] userInfo:result];
+ }
+ return nil;
+ }
+
+ if ([result objectForKey:@"error_msg"] != nil) {
+ if (error != nil) {
+ *error = [self formError:kGeneralErrorCode userInfo:result];
+ }
+ }
+
+ if ([result objectForKey:@"error_reason"] != nil) {
+ if (error != nil) {
+ *error = [self formError:kGeneralErrorCode userInfo:result];
+ }
+ }
+ }
+
+ return result;
+
+}
+
+/*
+ * private helper function: call the delegate function when the request
+ * fails with error
+ */
+- (void)failWithError:(NSError *)error {
+ if ([_delegate respondsToSelector:@selector(request:didFailWithError:)]) {
+ [_delegate request:self didFailWithError:error];
+ }
+}
+
+/*
+ * private helper function: handle the response data
+ */
+- (void)handleResponseData:(NSData *)data {
+ if ([_delegate respondsToSelector:
+ @selector(request:didLoadRawResponse:)]) {
+ [_delegate request:self didLoadRawResponse:data];
+ }
+
+ if ([_delegate respondsToSelector:@selector(request:didLoad:)] ||
+ [_delegate respondsToSelector:
+ @selector(request:didFailWithError:)]) {
+ NSError* error = nil;
+ id result = [self parseJsonResponse:data error:&error];
+
+ if (error) {
+ [self failWithError:error];
+ } else if ([_delegate respondsToSelector:
+ @selector(request:didLoad:)]) {
+ [_delegate request:self didLoad:(result == nil ? data : result)];
+ }
+
+ }
+
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+// public
+
+/**
+ * @return boolean - whether this request is processing
+ */
+- (BOOL)loading {
+ return !!_connection;
+}
+
+/**
+ * make the Facebook request
+ */
+- (void)connect {
+
+ if ([_delegate respondsToSelector:@selector(requestLoading:)]) {
+ [_delegate requestLoading:self];
+ }
+
+ NSString* url = [[self class] serializeURL:_url params:_params httpMethod:_httpMethod];
+ NSMutableURLRequest* request =
+ [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
+ cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+ timeoutInterval:kTimeoutInterval];
+ [request setValue:kUserAgent forHTTPHeaderField:@"User-Agent"];
+
+
+ [request setHTTPMethod:self.httpMethod];
+ if ([self.httpMethod isEqualToString: @"POST"]) {
+ NSString* contentType = [NSString
+ stringWithFormat:@"multipart/form-data; boundary=%@", kStringBoundary];
+ [request setValue:contentType forHTTPHeaderField:@"Content-Type"];
+
+ [request setHTTPBody:[self generatePostBody]];
+ }
+
+ _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
+
+}
+
+/**
+ * Free internal structure
+ */
+- (void)dealloc {
+ [_connection cancel];
+ [_connection release];
+ [_responseText release];
+ [_url release];
+ [_httpMethod release];
+ [_params release];
+ [super dealloc];
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+// NSURLConnectionDelegate
+
+- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
+ _responseText = [[NSMutableData alloc] init];
+
+ NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
+ if ([_delegate respondsToSelector:
+ @selector(request:didReceiveResponse:)]) {
+ [_delegate request:self didReceiveResponse:httpResponse];
+ }
+}
+
+- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
+ [_responseText appendData:data];
+}
+
+- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
+ willCacheResponse:(NSCachedURLResponse*)cachedResponse {
+ return nil;
+}
+
+- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
+ [self handleResponseData:_responseText];
+
+ [_responseText release];
+ _responseText = nil;
+ [_connection release];
+ _connection = nil;
+}
+
+- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+ [self failWithError:error];
+
+ [_responseText release];
+ _responseText = nil;
+ [_connection release];
+ _connection = nil;
+}
+
+@end
View
109 example/iOS/PhoneGapFacebookConnect/Plugins/FBPlugin/FB_src/Facebook.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2010 Facebook
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FBLoginDialog.h"
+#import "FBRequest.h"
+
+@protocol FBSessionDelegate;
+
+/**
+ * Main Facebook interface for interacting with the Facebook developer API.
+ * Provides methods to log in and log out a user, make requests using the REST
+ * and Graph APIs, and start user interface interactions (such as
+ * pop-ups promoting for credentials, permissions, stream posts, etc.)
+ */
+@interface Facebook : NSObject<FBLoginDialogDelegate>{
+ NSString* _accessToken;
+ NSDate* _expirationDate;
+ id<FBSessionDelegate> _sessionDelegate;
+ FBRequest* _request;
+ FBDialog* _loginDialog;
+ FBDialog* _fbDialog;
+ NSString* _appId;
+ NSArray* _permissions;
+}
+
+@property(nonatomic, copy) NSString* accessToken;
+
+@property(nonatomic, copy) NSDate* expirationDate;
+
+@property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate;
+
+- (id)initWithAppId:(NSString *)app_id;
+
+- (void)authorize:(NSArray *)permissions
+ delegate:(id<FBSessionDelegate>)delegate;
+
+- (BOOL)handleOpenURL:(NSURL *)url;
+
+- (void)logout:(id<FBSessionDelegate>)delegate;
+
+- (FBRequest*)requestWithParams:(NSMutableDictionary *)params
+ andDelegate:(id <FBRequestDelegate>)delegate;
+
+- (FBRequest*)requestWithMethodName:(NSString *)methodName
+ andParams:(NSMutableDictionary *)params
+ andHttpMethod:(NSString *)httpMethod
+ andDelegate:(id <FBRequestDelegate>)delegate;
+
+- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
+ andDelegate:(id <FBRequestDelegate>)delegate;
+
+- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
+ andParams:(NSMutableDictionary *)params
+ andDelegate:(id <FBRequestDelegate>)delegate;
+
+- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
+ andParams:(NSMutableDictionary *)params
+ andHttpMethod:(NSString *)httpMethod
+ andDelegate:(id <FBRequestDelegate>)delegate;
+
+- (void)dialog:(NSString *)action
+ andDelegate:(id<FBDialogDelegate>)delegate;
+
+- (void)dialog:(NSString *)action
+ andParams:(NSMutableDictionary *)params
+ andDelegate:(id <FBDialogDelegate>)delegate;
+
+- (BOOL)isSessionValid;
+
+@end
+
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Your application should implement this delegate to receive session callbacks.
+ */
+@protocol FBSessionDelegate <NSObject>
+
+@optional
+
+/**
+ * Called when the user successfully logged in.
+ */
+- (void)fbDidLogin;
+
+/**
+ * Called when the user dismissed the dialog without logging in.
+ */
+- (void)fbDidNotLogin:(BOOL)cancelled;
+