FBDialogs.h 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. /*
  2. * Copyright 2010-present Facebook.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <CoreLocation/CoreLocation.h>
  17. #import <UIKit/UIKit.h>
  18. #import "FBAppCall.h"
  19. #import "FBLinkShareParams.h"
  20. #import "FBOpenGraphActionParams.h"
  21. #import "FBPhotoParams.h"
  22. @class FBSession;
  23. @protocol FBOpenGraphAction;
  24. /*!
  25. @typedef FBNativeDialogResult enum
  26. @abstract
  27. Passed to a handler to indicate the result of a dialog being displayed to the user.
  28. */
  29. typedef NS_ENUM(NSUInteger, FBOSIntegratedShareDialogResult) {
  30. /*! Indicates that the dialog action completed successfully. */
  31. FBOSIntegratedShareDialogResultSucceeded = 0,
  32. /*! Indicates that the dialog action was cancelled (either by the user or the system). */
  33. FBOSIntegratedShareDialogResultCancelled = 1,
  34. /*! Indicates that the dialog could not be shown (because not on ios6 or ios6 auth was not used). */
  35. FBOSIntegratedShareDialogResultError = 2
  36. };
  37. /*!
  38. @typedef
  39. @abstract Defines a handler that will be called in response to the native share dialog
  40. being displayed.
  41. */
  42. typedef void (^FBOSIntegratedShareDialogHandler)(FBOSIntegratedShareDialogResult result, NSError *error);
  43. /*!
  44. @typedef FBDialogAppCallCompletionHandler
  45. @abstract
  46. A block that when passed to a method in FBDialogs is called back
  47. with the results of the AppCall for that dialog.
  48. @discussion
  49. This will be called on the UI thread, once the AppCall completes.
  50. @param call The `FBAppCall` that was completed.
  51. @param results The results of the AppCall for the dialog. This parameters is present
  52. purely for convenience, and is the exact same value as call.dialogData.results.
  53. @param error The `NSError` representing any error that occurred. This parameters is
  54. present purely for convenience, and is the exact same value as call.error.
  55. */
  56. typedef void (^FBDialogAppCallCompletionHandler)(
  57. FBAppCall *call,
  58. NSDictionary *results,
  59. NSError *error);
  60. /*!
  61. @class FBDialogs
  62. @abstract
  63. Provides methods to display native (i.e., non-Web-based) dialogs to the user.
  64. @discussion
  65. If you are building an app with a urlSchemeSuffix, you should also set the appropriate
  66. plist entry. See `[FBSettings defaultUrlSchemeSuffix]`.
  67. */
  68. @interface FBDialogs : NSObject
  69. #pragma mark - OSIntegratedShareDialog
  70. /*!
  71. @abstract
  72. Presents a dialog that allows the user to share a status update that may include
  73. text, images, or URLs. This dialog is only available on iOS 6.0 and above. The
  74. current active session returned by [FBSession activeSession] will be used to determine
  75. whether the dialog will be displayed. If a session is active, it must be open and the
  76. login method used to authenticate the user must be native iOS 6.0 authentication.
  77. If no session active, then whether the call succeeds or not will depend on
  78. whether Facebook integration has been configured.
  79. @param viewController The view controller which will present the dialog.
  80. @param initialText The text which will initially be populated in the dialog. The user
  81. will have the opportunity to edit this text before posting it. May be nil.
  82. @param image A UIImage that will be attached to the status update. May be nil.
  83. @param url An NSURL that will be attached to the status update. May be nil.
  84. @param handler A handler that will be called when the dialog is dismissed, or if an error
  85. occurs. May be nil.
  86. @return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
  87. will still be called, with an error indicating the reason the dialog was not displayed)
  88. */
  89. + (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController *)viewController
  90. initialText:(NSString *)initialText
  91. image:(UIImage *)image
  92. url:(NSURL *)url
  93. handler:(FBOSIntegratedShareDialogHandler)handler;
  94. /*!
  95. @abstract
  96. Presents a dialog that allows the user to share a status update that may include
  97. text, images, or URLs. This dialog is only available on iOS 6.0 and above. The
  98. current active session returned by [FBSession activeSession] will be used to determine
  99. whether the dialog will be displayed. If a session is active, it must be open and the
  100. login method used to authenticate the user must be native iOS 6.0 authentication.
  101. If no session active, then whether the call succeeds or not will depend on
  102. whether Facebook integration has been configured.
  103. @param viewController The view controller which will present the dialog.
  104. @param initialText The text which will initially be populated in the dialog. The user
  105. will have the opportunity to edit this text before posting it. May be nil.
  106. @param images An array of UIImages that will be attached to the status update. May
  107. be nil.
  108. @param urls An array of NSURLs that will be attached to the status update. May be nil.
  109. @param handler A handler that will be called when the dialog is dismissed, or if an error
  110. occurs. May be nil.
  111. @return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
  112. will still be called, with an error indicating the reason the dialog was not displayed)
  113. */
  114. + (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController *)viewController
  115. initialText:(NSString *)initialText
  116. images:(NSArray *)images
  117. urls:(NSArray *)urls
  118. handler:(FBOSIntegratedShareDialogHandler)handler;
  119. /*!
  120. @abstract
  121. Presents a dialog that allows the user to share a status update that may include
  122. text, images, or URLs. This dialog is only available on iOS 6.0 and above. An
  123. <FBSession> may be specified, or nil may be passed to indicate that the current
  124. active session should be used. If a session is specified (whether explicitly or by
  125. virtue of being the active session), it must be open and the login method used to
  126. authenticate the user must be native iOS 6.0 authentication. If no session is specified
  127. (and there is no active session), then whether the call succeeds or not will depend on
  128. whether Facebook integration has been configured.
  129. @param viewController The view controller which will present the dialog.
  130. @param session The <FBSession> to use to determine whether or not the user has been
  131. authenticated with iOS native authentication. If nil, then [FBSession activeSession]
  132. will be checked. See discussion above for the implications of nil or non-nil session.
  133. @param initialText The text which will initially be populated in the dialog. The user
  134. will have the opportunity to edit this text before posting it. May be nil.
  135. @param images An array of UIImages that will be attached to the status update. May
  136. be nil.
  137. @param urls An array of NSURLs that will be attached to the status update. May be nil.
  138. @param handler A handler that will be called when the dialog is dismissed, or if an error
  139. occurs. May be nil.
  140. @return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
  141. will still be called, with an error indicating the reason the dialog was not displayed)
  142. */
  143. + (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController *)viewController
  144. session:(FBSession *)session
  145. initialText:(NSString *)initialText
  146. images:(NSArray *)images
  147. urls:(NSArray *)urls
  148. handler:(FBOSIntegratedShareDialogHandler)handler;
  149. /*!
  150. @abstract Determines if the device is capable of presenting the OS integrated share dialog.
  151. @discussion This is the most basic check for capability for this feature.
  152. @see canPresentOSIntegratedShareDialogWithSession:
  153. */
  154. + (BOOL)canPresentOSIntegratedShareDialog;
  155. /*!
  156. @abstract
  157. Determines whether a call to presentShareDialogModallyFrom: will successfully present
  158. a dialog. This is useful for applications that need to modify the available UI controls
  159. depending on whether the dialog is available on the current platform and for the current
  160. user.
  161. @param session The <FBSession> to use to determine whether or not the user has been
  162. authenticated with iOS native authentication. If nil, then [FBSession activeSession]
  163. will be checked. See discussion above for the implications of nil or non-nil session.
  164. @return YES if the dialog would be presented for the session, and NO if not
  165. */
  166. + (BOOL)canPresentOSIntegratedShareDialogWithSession:(FBSession *)session;
  167. #pragma mark - Native Share Dialog
  168. /*!
  169. @abstract Determines if the device is capable of presenting the share dialog.
  170. @discussion This is the most basic check for capability for this feature.
  171. @see canPresentShareDialogWithOpenGraphActionParams:
  172. @see canPresentShareDialogWithParams:
  173. @see canPresentShareDialogWithPhotos:
  174. */
  175. + (BOOL)canPresentShareDialog;
  176. /*!
  177. @abstract
  178. Determines whether a call to presentShareDialogWithOpenGraphActionParams:clientState:handler:
  179. will successfully present a dialog in the Facebook application. This is useful for applications
  180. that need to modify the available UI controls depending on whether the dialog is
  181. available on the current platform.
  182. @param params The parameters for the FB share dialog.
  183. @return YES if the dialog would be presented, and NO if not
  184. @discussion A return value of YES here indicates that the corresponding
  185. presentShareDialogWithOpenGraphActionParams method will return a non-nil FBAppCall for
  186. the same params. And vice versa.
  187. */
  188. + (BOOL)canPresentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionParams *)params;
  189. /*!
  190. @abstract
  191. Determines whether a call to presentShareDialogWithTarget: will successfully
  192. present a dialog in the Facebook application. This is useful for applications that
  193. need to modify the available UI controls depending on whether the dialog is
  194. available on the current platform.
  195. @param params The parameters for the FB share dialog.
  196. @return YES if the dialog would be presented, and NO if not
  197. @discussion A return value of YES here indicates that the corresponding
  198. presentShareDialogWithParams method will return a non-nil FBAppCall for the same
  199. params. And vice versa.
  200. */
  201. + (BOOL)canPresentShareDialogWithParams:(FBLinkShareParams *)params;
  202. /*!
  203. @abstract
  204. Determines whether a call to presentShareDialogWithPhotoParams: will successfully
  205. present a dialog in the Facebook application. This is useful for applications that
  206. need to modify the available UI controls depending on whether the dialog is
  207. available on the current platform.
  208. @return YES if the dialog would be presented, and NO if not
  209. @discussion A return value of YES here indicates that the corresponding
  210. presentShareDialogWithPhotoParams method will return a non-nil FBAppCall.
  211. */
  212. + (BOOL)canPresentShareDialogWithPhotos;
  213. /*!
  214. @abstract
  215. Presents a dialog in the Facebook application that allows the user to share a status
  216. update that may include text, images, or URLs. No session is required, and the app
  217. does not need to be authorized to call this.
  218. Note that this will perform an app switch to the Facebook app, and will cause the
  219. current app to be suspended. When the share is complete, the Facebook app will redirect
  220. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  221. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  222. the appropriate handling. Note that FBAppCall will first try to call the completion
  223. handler associated with this method, but since during an app switch, the calling app
  224. may be suspended or killed, the app must also give a fallbackHandler to the
  225. handleOpenURL: method in FBAppCall.
  226. @param params The parameters for the FB share dialog.
  227. @param clientState An NSDictionary that's passed through when the completion handler
  228. is called. This is useful for the app to maintain state about the share request that
  229. was made so as to have appropriate action when the handler is called. May be nil.
  230. @param handler A completion handler that may be called when the status update is
  231. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  232. @return An FBAppCall object that will also be passed into the provided
  233. FBAppCallCompletionHandler.
  234. @discussion A non-nil FBAppCall object is only returned if the corresponding
  235. canPresentShareDialogWithParams method is also returning YES for the same params.
  236. */
  237. + (FBAppCall *)presentShareDialogWithParams:(FBLinkShareParams *)params
  238. clientState:(NSDictionary *)clientState
  239. handler:(FBDialogAppCallCompletionHandler)handler;
  240. /*!
  241. @abstract
  242. Presents a dialog in the Facebook application that allows the user to share the
  243. supplied link. No session is required, and the app does not need to be authorized
  244. to call this.
  245. Note that this will perform an app switch to the Facebook app, and will cause the
  246. current app to be suspended. When the share is complete, the Facebook app will redirect
  247. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  248. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  249. the appropriate handling. Note that FBAppCall will first try to call the completion
  250. handler associated with this method, but since during an app switch, the calling app
  251. may be suspended or killed, the app must also give a fallbackHandler to the
  252. handleOpenURL: method in FBAppCall.
  253. @param link The URL link to be attached to the post.
  254. @param handler A completion handler that may be called when the status update is
  255. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  256. @return An FBAppCall object that will also be passed into the provided
  257. FBAppCallCompletionHandler.
  258. @discussion A non-nil FBAppCall object is only returned if the corresponding
  259. canPresentShareDialogWithParams method is also returning YES for the same params.
  260. */
  261. + (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
  262. handler:(FBDialogAppCallCompletionHandler)handler;
  263. /*!
  264. @abstract
  265. Presents a dialog in the Facebook application that allows the user to share the
  266. supplied link. No session is required, and the app does not need to be authorized
  267. to call this.
  268. Note that this will perform an app switch to the Facebook app, and will cause the
  269. current app to be suspended. When the share is complete, the Facebook app will redirect
  270. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  271. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  272. the appropriate handling. Note that FBAppCall will first try to call the completion
  273. handler associated with this method, but since during an app switch, the calling app
  274. may be suspended or killed, the app must also give a fallbackHandler to the
  275. handleOpenURL: method in FBAppCall.
  276. @param link The URL link to be attached to the post.
  277. @param name The name, or title associated with the link. May be nil.
  278. @param handler A completion handler that may be called when the status update is
  279. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  280. @return An FBAppCall object that will also be passed into the provided
  281. FBAppCallCompletionHandler.
  282. @discussion A non-nil FBAppCall object is only returned if the corresponding
  283. canPresentShareDialogWithParams method is also returning YES for the same params.
  284. */
  285. + (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
  286. name:(NSString *)name
  287. handler:(FBDialogAppCallCompletionHandler)handler;
  288. /*!
  289. @abstract
  290. Presents a dialog in the Facebook application that allows the user to share the
  291. supplied link. No session is required, and the app does not need to be authorized
  292. to call this.
  293. Note that this will perform an app switch to the Facebook app, and will cause the
  294. current app to be suspended. When the share is complete, the Facebook app will redirect
  295. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  296. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  297. the appropriate handling. Note that FBAppCall will first try to call the completion
  298. handler associated with this method, but since during an app switch, the calling app
  299. may be suspended or killed, the app must also give a fallbackHandler to the
  300. handleOpenURL: method in FBAppCall.
  301. @param link The URL link to be attached to the post.
  302. @param name The name, or title associated with the link. May be nil.
  303. @param caption The caption to be used with the link. May be nil.
  304. @param description The description associated with the link. May be nil.
  305. @param picture The link to a thumbnail to associate with the link. May be nil.
  306. @param clientState An NSDictionary that's passed through when the completion handler
  307. is called. This is useful for the app to maintain state about the share request that
  308. was made so as to have appropriate action when the handler is called. May be nil.
  309. @param handler A completion handler that may be called when the status update is
  310. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  311. @return An FBAppCall object that will also be passed into the provided
  312. FBAppCallCompletionHandler.
  313. @discussion A non-nil FBAppCall object is only returned if the corresponding
  314. canPresentShareDialogWithParams method is also returning YES for the same params.
  315. */
  316. + (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
  317. name:(NSString *)name
  318. caption:(NSString *)caption
  319. description:(NSString *)description
  320. picture:(NSURL *)picture
  321. clientState:(NSDictionary *)clientState
  322. handler:(FBDialogAppCallCompletionHandler)handler;
  323. /*!
  324. @abstract
  325. Presents a dialog in the Facebook application that allows the user to share the
  326. supplied photo(s). No session is required, and the app does not need to be authorized
  327. to call this.
  328. Note that this will perform an app switch to the Facebook app, and will cause the
  329. current app to be suspended. When the share is complete, the Facebook app will redirect
  330. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  331. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  332. the appropriate handling. Note that FBAppCall will first try to call the completion
  333. handler associated with this method, but since during an app switch, the calling app
  334. may be suspended or killed, the app must also give a fallbackHandler to the
  335. handleOpenURL: method in FBAppCall.
  336. @param params The parameters for the FB share dialog.
  337. @param clientState An NSDictionary that's passed through when the completion handler
  338. is called. This is useful for the app to maintain state about the share request that
  339. was made so as to have appropriate action when the handler is called. May be nil.
  340. @param handler A completion handler that may be called when the status update is
  341. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  342. @return An FBAppCall object that will also be passed into the provided
  343. FBAppCallCompletionHandler.
  344. @discussion A non-nil FBAppCall object is only returned if the corresponding
  345. canPresentShareDialogWithPhotoParams method is also returning YES for the same params.
  346. */
  347. + (FBAppCall *)presentShareDialogWithPhotoParams:(FBPhotoParams *)params
  348. clientState:(NSDictionary *)clientState
  349. handler:(FBDialogAppCallCompletionHandler)handler;
  350. /*!
  351. @abstract
  352. Presents a dialog in the Facebook application that allows the user to share the
  353. supplied photo(s). No session is required, and the app does not need to be authorized
  354. to call this.
  355. Note that this will perform an app switch to the Facebook app, and will cause the
  356. current app to be suspended. When the share is complete, the Facebook app will redirect
  357. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  358. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  359. the appropriate handling. Note that FBAppCall will first try to call the completion
  360. handler associated with this method, but since during an app switch, the calling app
  361. may be suspended or killed, the app must also give a fallbackHandler to the
  362. handleOpenURL: method in FBAppCall.
  363. @param photos An NSArray containing UIImages to be shared. May be nil.
  364. @param handler A completion handler that may be called when the status update is
  365. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  366. @return An FBAppCall object that will also be passed into the provided
  367. FBAppCallCompletionHandler.
  368. @discussion A non-nil FBAppCall object is only returned if the corresponding
  369. canPresentShareDialogWithPhotoParams method is also returning YES for the same params.
  370. */
  371. + (FBAppCall *)presentShareDialogWithPhotos:(NSArray *)photos
  372. handler:(FBDialogAppCallCompletionHandler)handler;
  373. /*!
  374. @abstract
  375. Presents a dialog in the Facebook application that allows the user to share the
  376. supplied photo(s). No session is required, and the app does not need to be authorized
  377. to call this.
  378. Note that this will perform an app switch to the Facebook app, and will cause the
  379. current app to be suspended. When the share is complete, the Facebook app will redirect
  380. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  381. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  382. the appropriate handling. Note that FBAppCall will first try to call the completion
  383. handler associated with this method, but since during an app switch, the calling app
  384. may be suspended or killed, the app must also give a fallbackHandler to the
  385. handleOpenURL: method in FBAppCall.
  386. @param photos An NSArray containing UIImages to be shared.
  387. @param clientState An NSDictionary that's passed through when the completion handler
  388. is called. This is useful for the app to maintain state about the share request that
  389. was made so as to have appropriate action when the handler is called. May be nil.
  390. @param handler A completion handler that may be called when the status update is
  391. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  392. @return An FBAppCall object that will also be passed into the provided
  393. FBAppCallCompletionHandler.
  394. @discussion A non-nil FBAppCall object is only returned if the corresponding
  395. canPresentShareDialogWithPhotoParams method is also returning YES for the same params.
  396. */
  397. + (FBAppCall *)presentShareDialogWithPhotos:(NSArray *)photos
  398. clientState:(NSDictionary *)clientState
  399. handler:(FBDialogAppCallCompletionHandler)handler;
  400. /*!
  401. @abstract
  402. Presents a dialog in the Facebook application that allows the user to publish an Open
  403. Graph action. No session is required, and the app does not need to be authorized to call
  404. this.
  405. Note that this will perform an app switch to the Facebook app, and will cause the
  406. current app to be suspended. When the share is complete, the Facebook app will redirect
  407. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  408. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  409. the appropriate handling. Note that FBAppCall will first try to call the completion
  410. handler associated with this method, but since during an app switch, the calling app
  411. may be suspended or killed, the app must also give a fallbackHandler to the
  412. handleOpenURL: method in FBAppCall.
  413. @param params The parameters for the Open Graph action dialog.
  414. @param clientState An NSDictionary that's passed through when the completion handler
  415. is called. This is useful for the app to maintain state about the share request that
  416. was made so as to have appropriate action when the handler is called. May be nil.
  417. @param handler A completion handler that may be called when the status update is
  418. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  419. @return An FBAppCall object that will also be passed into the provided
  420. FBAppCallCompletionHandler.
  421. @discussion A non-nil FBAppCall object is only returned if the corresponding
  422. canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
  423. */
  424. + (FBAppCall *)presentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionParams *)params
  425. clientState:(NSDictionary *)clientState
  426. handler:(FBDialogAppCallCompletionHandler)handler;
  427. /*!
  428. @abstract
  429. Presents a dialog in the Facebook application that allows the user to publish the
  430. supplied Open Graph action. No session is required, and the app does not need to be
  431. authorized to call this.
  432. Note that this will perform an app switch to the Facebook app, and will cause the
  433. current app to be suspended. When the share is complete, the Facebook app will redirect
  434. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  435. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  436. the appropriate handling. Note that FBAppCall will first try to call the completion
  437. handler associated with this method, but since during an app switch, the calling app
  438. may be suspended or killed, the app must also give a fallbackHandler to the
  439. handleOpenURL: method in FBAppCall.
  440. @param action The Open Graph action to be published. May not be nil.
  441. @param actionType the fully-specified Open Graph action type of the action (e.g.,
  442. my_app_namespace:my_action).
  443. @param previewPropertyName the name of the property on the action that represents the
  444. primary Open Graph object associated with the action; this object will be displayed in the
  445. preview portion of the share dialog.
  446. @param handler A completion handler that may be called when the status update is
  447. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  448. @return An FBAppCall object that will also be passed into the provided
  449. FBAppCallCompletionHandler.
  450. @discussion A non-nil FBAppCall object is only returned if the corresponding
  451. canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
  452. */+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
  453. actionType:(NSString *)actionType
  454. previewPropertyName:(NSString *)previewPropertyName
  455. handler:(FBDialogAppCallCompletionHandler)handler;
  456. /*!
  457. @abstract
  458. Presents a dialog in the Facebook application that allows the user to publish the
  459. supplied Open Graph action. No session is required, and the app does not need to be
  460. authorized to call this.
  461. Note that this will perform an app switch to the Facebook app, and will cause the
  462. current app to be suspended. When the share is complete, the Facebook app will redirect
  463. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  464. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  465. the appropriate handling. Note that FBAppCall will first try to call the completion
  466. handler associated with this method, but since during an app switch, the calling app
  467. may be suspended or killed, the app must also give a fallbackHandler to the
  468. handleOpenURL: method in FBAppCall.
  469. @param action The Open Graph action to be published. May not be nil.
  470. @param actionType the fully-specified Open Graph action type of the action (e.g.,
  471. my_app_namespace:my_action).
  472. @param previewPropertyName the name of the property on the action that represents the
  473. primary Open Graph object associated with the action; this object will be displayed in the
  474. preview portion of the share dialog.
  475. @param clientState An NSDictionary that's passed through when the completion handler
  476. is called. This is useful for the app to maintain state about the share request that
  477. was made so as to have appropriate action when the handler is called. May be nil.
  478. @param handler A completion handler that may be called when the status update is
  479. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  480. @return An FBAppCall object that will also be passed into the provided
  481. FBAppCallCompletionHandler.
  482. @discussion A non-nil FBAppCall object is only returned if the corresponding
  483. canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
  484. */
  485. + (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
  486. actionType:(NSString *)actionType
  487. previewPropertyName:(NSString *)previewPropertyName
  488. clientState:(NSDictionary *)clientState
  489. handler:(FBDialogAppCallCompletionHandler)handler;
  490. #pragma mark - Message Dialog
  491. /*!
  492. @abstract Determines if the device is capable of presenting the message dialog.
  493. @discussion This is the most basic check for capability for this feature.
  494. @see canPresentMessageDialogWithOpenGraphActionParams:
  495. @see canPresentMessageDialogWithParams:
  496. @see canPresentMessageDialogWithPhotos:
  497. */
  498. + (BOOL)canPresentMessageDialog;
  499. /*!
  500. @abstract
  501. Determines whether a call to `presentMessageDialogWithOpenGraphActionParams:...` will
  502. successfully present a dialog in the Facebook Messenger app. This is useful for applications
  503. that need to modify the available UI controls depending on whether the dialog is
  504. available on the current platform.
  505. @param params the dialog parameters
  506. @return YES if the dialog would be presented, and NO if not
  507. */
  508. + (BOOL)canPresentMessageDialogWithOpenGraphActionParams:(FBOpenGraphActionParams *)params;
  509. /*!
  510. @abstract
  511. Determines whether a call to `presentMessageDialogWithParams:...` will successfully
  512. present a dialog in the Facebook Messenger app. This is useful for applications that
  513. need to modify the available UI controls depending on whether the dialog is
  514. available on the current platform.
  515. @param params the dialog parameters
  516. @return YES if the dialog would be presented, and NO if not
  517. */
  518. + (BOOL)canPresentMessageDialogWithParams:(FBLinkShareParams *)params;
  519. /*!
  520. @abstract
  521. Determines whether a call to `presentMessageDialogWithPhotos:...` will successfully
  522. present a dialog in the Facebook Messenger app. This is useful for applications that
  523. need to modify the available UI controls depending on whether the dialog is
  524. available on the current platform.
  525. @return YES if the dialog would be presented, and NO if not
  526. */
  527. + (BOOL)canPresentMessageDialogWithPhotos;
  528. /*!
  529. @abstract
  530. Presents a dialog in the Facebook Messenger app that allows the user to publish an Open
  531. Graph action. No session is required, and the app does not need to be authorized to call
  532. this.
  533. Note that this will perform an app switch to the Messenger app, and will cause the
  534. current app to be suspended. When the share is complete, the Messenger app will redirect
  535. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  536. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  537. the appropriate handling. Note that FBAppCall will first try to call the completion
  538. handler associated with this method, but since during an app switch, the calling app
  539. may be suspended or killed, the app must also give a fallbackHandler to the
  540. handleOpenURL: method in FBAppCall.
  541. @param params The parameters for the Open Graph action dialog.
  542. @param clientState An NSDictionary that's passed through when the completion handler
  543. is called. This is useful for the app to maintain state about the share request that
  544. was made so as to have appropriate action when the handler is called. May be nil.
  545. @param handler A completion handler that may be called when the status update is
  546. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  547. @return An FBAppCall object that will also be passed into the provided
  548. FBAppCallCompletionHandler.
  549. @discussion A non-nil FBAppCall object is only returned if the corresponding
  550. `canPresentMessageDialogWithOpenGraphActionParams:` method is also returning YES for the same params.
  551. */
  552. + (FBAppCall *)presentMessageDialogWithOpenGraphActionParams:(FBOpenGraphActionParams *)params
  553. clientState:(NSDictionary *)clientState
  554. handler:(FBDialogAppCallCompletionHandler)handler;
  555. /*!
  556. @abstract
  557. Presents a dialog in the Facebook Messenger app that allows the user to publish the
  558. supplied Open Graph action. No session is required, and the app does not need to be
  559. authorized to call this.
  560. Note that this will perform an app switch to the Messenger app, and will cause the
  561. current app to be suspended. When the share is complete, the Messenger app will redirect
  562. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  563. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  564. the appropriate handling. Note that FBAppCall will first try to call the completion
  565. handler associated with this method, but since during an app switch, the calling app
  566. may be suspended or killed, the app must also give a fallbackHandler to the
  567. handleOpenURL: method in FBAppCall.
  568. @param action The Open Graph action to be published. May not be nil.
  569. @param actionType the fully-specified Open Graph action type of the action (e.g.,
  570. my_app_namespace:my_action).
  571. @param previewPropertyName the name of the property on the action that represents the
  572. primary Open Graph object associated with the action; this object will be displayed in the
  573. preview portion of the share dialog.
  574. @param handler A completion handler that may be called when the status update is
  575. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  576. @return An FBAppCall object that will also be passed into the provided
  577. FBAppCallCompletionHandler.
  578. @discussion A non-nil FBAppCall object is only returned if the corresponding
  579. canPresentMessageDialogWithOpenGraphActionParams method is also returning YES for the same params.
  580. */+ (FBAppCall *)presentMessageDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
  581. actionType:(NSString *)actionType
  582. previewPropertyName:(NSString *)previewPropertyName
  583. handler:(FBDialogAppCallCompletionHandler)handler;
  584. /*!
  585. @abstract
  586. Presents a dialog in the Facebook Messenger app that allows the user to publish the
  587. supplied Open Graph action. No session is required, and the app does not need to be
  588. authorized to call this.
  589. Note that this will perform an app switch to the Messenger app, and will cause the
  590. current app to be suspended. When the share is complete, the Messenger app will redirect
  591. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  592. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  593. the appropriate handling. Note that FBAppCall will first try to call the completion
  594. handler associated with this method, but since during an app switch, the calling app
  595. may be suspended or killed, the app must also give a fallbackHandler to the
  596. handleOpenURL: method in FBAppCall.
  597. @param action The Open Graph action to be published. May not be nil.
  598. @param actionType the fully-specified Open Graph action type of the action (e.g.,
  599. my_app_namespace:my_action).
  600. @param previewPropertyName the name of the property on the action that represents the
  601. primary Open Graph object associated with the action; this object will be displayed in the
  602. preview portion of the share dialog.
  603. @param clientState An NSDictionary that's passed through when the completion handler
  604. is called. This is useful for the app to maintain state about the share request that
  605. was made so as to have appropriate action when the handler is called. May be nil.
  606. @param handler A completion handler that may be called when the status update is
  607. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  608. @return An FBAppCall object that will also be passed into the provided
  609. FBAppCallCompletionHandler.
  610. @discussion A non-nil FBAppCall object is only returned if the corresponding
  611. canPresentMessageDialogWithOpenGraphActionParams method is also returning YES for the same params.
  612. */
  613. + (FBAppCall *)presentMessageDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
  614. actionType:(NSString *)actionType
  615. previewPropertyName:(NSString *)previewPropertyName
  616. clientState:(NSDictionary *)clientState
  617. handler:(FBDialogAppCallCompletionHandler)handler;
  618. /*!
  619. @abstract
  620. Presents a dialog in the Facebook Messenger app that allows the user to send the
  621. supplied photo(s). No session is required, and the app does not need to be authorized
  622. to call this.
  623. Note that this will perform an app switch to the Messenger app, and will cause the
  624. current app to be suspended. When the share is complete, the Messenger app will redirect
  625. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  626. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  627. the appropriate handling. Note that FBAppCall will first try to call the completion
  628. handler associated with this method, but since during an app switch, the calling app
  629. may be suspended or killed, the app must also give a fallbackHandler to the
  630. handleOpenURL: method in FBAppCall.
  631. @param params The parameters for the Message Dialog
  632. @param clientState An NSDictionary that's passed through when the completion handler
  633. is called. This is useful for the app to maintain state about the share request that
  634. was made so as to have appropriate action when the handler is called. May be nil.
  635. @param handler A completion handler that may be called when the status update is
  636. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  637. @return An FBAppCall object that will also be passed into the provided
  638. FBAppCallCompletionHandler.
  639. @discussion A non-nil FBAppCall object is only returned if the corresponding
  640. `canPresentMessageDialogWithPhotos` method is also returning YES.
  641. */
  642. + (FBAppCall *)presentMessageDialogWithPhotoParams:(FBPhotoParams *)params
  643. clientState:(NSDictionary *)clientState
  644. handler:(FBDialogAppCallCompletionHandler)handler;
  645. /*!
  646. @abstract
  647. Presents a dialog in the Facebook Messenger app that allows the user to send the
  648. supplied photo(s). No session is required, and the app does not need to be authorized
  649. to call this.
  650. Note that this will perform an app switch to the Messenger app, and will cause the
  651. current app to be suspended. When the share is complete, the Messenger app will redirect
  652. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  653. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  654. the appropriate handling. Note that FBAppCall will first try to call the completion
  655. handler associated with this method, but since during an app switch, the calling app
  656. may be suspended or killed, the app must also give a fallbackHandler to the
  657. handleOpenURL: method in FBAppCall.
  658. @param photos An NSArray containing UIImages to be shared.
  659. @param handler A completion handler that may be called when the status update is
  660. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  661. @return An FBAppCall object that will also be passed into the provided
  662. FBAppCallCompletionHandler.
  663. @discussion A non-nil FBAppCall object is only returned if the corresponding
  664. `canPresentMessageDialogWithPhotos` method is also returning YES.
  665. */
  666. + (FBAppCall *)presentMessageDialogWithPhotos:(NSArray *)photos
  667. handler:(FBDialogAppCallCompletionHandler)handler;
  668. /*!
  669. @abstract
  670. Presents a dialog in the Facebook Messenger app that allows the user to send the
  671. supplied photo(s). No session is required, and the app does not need to be authorized
  672. to call this.
  673. Note that this will perform an app switch to the Messenger app, and will cause the
  674. current app to be suspended. When the share is complete, the Messenger app will redirect
  675. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  676. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  677. the appropriate handling. Note that FBAppCall will first try to call the completion
  678. handler associated with this method, but since during an app switch, the calling app
  679. may be suspended or killed, the app must also give a fallbackHandler to the
  680. handleOpenURL: method in FBAppCall.
  681. @param photos An NSArray containing UIImages to be shared.
  682. @param clientState An NSDictionary that's passed through when the completion handler
  683. is called. This is useful for the app to maintain state about the share request that
  684. was made so as to have appropriate action when the handler is called. May be nil.
  685. @param handler A completion handler that may be called when the status update is
  686. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  687. @return An FBAppCall object that will also be passed into the provided
  688. FBAppCallCompletionHandler.
  689. @discussion A non-nil FBAppCall object is only returned if the corresponding
  690. `canPresentMessageDialogWithPhotos` method is also returning YES.
  691. */
  692. + (FBAppCall *)presentMessageDialogWithPhotos:(NSArray *)photos
  693. clientState:(NSDictionary *)clientState
  694. handler:(FBDialogAppCallCompletionHandler)handler;
  695. /*!
  696. @abstract
  697. Presents a dialog in the Facebook Messenger app that allows the user to share a status
  698. update that may include text, images, or URLs. No session is required, and the app
  699. does not need to be authorized to call this.
  700. Note that this will perform an app switch to the Messenger app, and will cause the
  701. current app to be suspended. When the share is complete, the Messenger app will redirect
  702. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  703. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  704. the appropriate handling. Note that FBAppCall will first try to call the completion
  705. handler associated with this method, but since during an app switch, the calling app
  706. may be suspended or killed, the app must also give a fallbackHandler to the
  707. handleOpenURL: method in FBAppCall.
  708. @param params The parameters for the Message Dialog. The "friends" and "place" properties
  709. will be ignored as the Facebook Messenger app does not support tagging.
  710. @param clientState An NSDictionary that's passed through when the completion handler
  711. is called. This is useful for the app to maintain state about the share request that
  712. was made so as to have appropriate action when the handler is called. May be nil.
  713. @param handler A completion handler that may be called when the status update is
  714. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  715. @return An FBAppCall object that will also be passed into the provided
  716. FBAppCallCompletionHandler.
  717. @discussion A non-nil FBAppCall object is only returned if the corresponding
  718. `canPresentMessageDialogWithParams:` method is also returning YES for the same params.
  719. */
  720. + (FBAppCall *)presentMessageDialogWithParams:(FBLinkShareParams *)params
  721. clientState:(NSDictionary *)clientState
  722. handler:(FBDialogAppCallCompletionHandler)handler;
  723. /*!
  724. @abstract
  725. Presents a dialog in the Facebook Messenger app that allows the user to share the
  726. supplied link. No session is required, and the app does not need to be authorized
  727. to call this.
  728. Note that this will perform an app switch to the Messenger app, and will cause the
  729. current app to be suspended. When the share is complete, the Messenger app will redirect
  730. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  731. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  732. the appropriate handling. Note that FBAppCall will first try to call the completion
  733. handler associated with this method, but since during an app switch, the calling app
  734. may be suspended or killed, the app must also give a fallbackHandler to the
  735. handleOpenURL: method in FBAppCall.
  736. @param link The URL link to be attached to the post.
  737. @param handler A completion handler that may be called when the status update is
  738. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  739. @return An FBAppCall object that will also be passed into the provided
  740. FBAppCallCompletionHandler.
  741. @discussion A non-nil FBAppCall object is only returned if the corresponding
  742. canPresentMessageDialogWithParams method is also returning YES for the same params.
  743. */
  744. + (FBAppCall *)presentMessageDialogWithLink:(NSURL *)link
  745. handler:(FBDialogAppCallCompletionHandler)handler;
  746. /*!
  747. @abstract
  748. Presents a dialog in the Facebook Messenger app that allows the user to share the
  749. supplied link. No session is required, and the app does not need to be authorized
  750. to call this.
  751. Note that this will perform an app switch to the Messenger app, and will cause the
  752. current app to be suspended. When the share is complete, the Messenger app will redirect
  753. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  754. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  755. the appropriate handling. Note that FBAppCall will first try to call the completion
  756. handler associated with this method, but since during an app switch, the calling app
  757. may be suspended or killed, the app must also give a fallbackHandler to the
  758. handleOpenURL: method in FBAppCall.
  759. @param link The URL link to be attached to the post.
  760. @param name The name, or title associated with the link. May be nil.
  761. @param handler A completion handler that may be called when the status update is
  762. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  763. @return An FBAppCall object that will also be passed into the provided
  764. FBAppCallCompletionHandler.
  765. @discussion A non-nil FBAppCall object is only returned if the corresponding
  766. canPresentMessageDialogWithParams method is also returning YES for the same params.
  767. */
  768. + (FBAppCall *)presentMessageDialogWithLink:(NSURL *)link
  769. name:(NSString *)name
  770. handler:(FBDialogAppCallCompletionHandler)handler;
  771. /*!
  772. @abstract
  773. Presents a dialog in the Facebook Messenger app that allows the user to share the
  774. supplied link. No session is required, and the app does not need to be authorized
  775. to call this.
  776. Note that this will perform an app switch to the Messenger app, and will cause the
  777. current app to be suspended. When the share is complete, the Messenger app will redirect
  778. to a url of the form "fb{APP_ID}://" that the application must handle. The app should
  779. then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
  780. the appropriate handling. Note that FBAppCall will first try to call the completion
  781. handler associated with this method, but since during an app switch, the calling app
  782. may be suspended or killed, the app must also give a fallbackHandler to the
  783. handleOpenURL: method in FBAppCall.
  784. @param link The URL link to be attached to the post.
  785. @param name The name, or title associated with the link. May be nil.
  786. @param caption The caption to be used with the link. May be nil.
  787. @param description The description associated with the link. May be nil.
  788. @param picture The link to a thumbnail to associate with the link. May be nil.
  789. @param clientState An NSDictionary that's passed through when the completion handler
  790. is called. This is useful for the app to maintain state about the share request that
  791. was made so as to have appropriate action when the handler is called. May be nil.
  792. @param handler A completion handler that may be called when the status update is
  793. complete. May be nil. If non-nil, the handler will always be called asynchronously.
  794. @return An FBAppCall object that will also be passed into the provided
  795. FBAppCallCompletionHandler.
  796. @discussion A non-nil FBAppCall object is only returned if the corresponding
  797. canPresentMessageDialogWithParams method is also returning YES for the same params.
  798. */
  799. + (FBAppCall *)presentMessageDialogWithLink:(NSURL *)link
  800. name:(NSString *)name
  801. caption:(NSString *)caption
  802. description:(NSString *)description
  803. picture:(NSURL *)picture
  804. clientState:(NSDictionary *)clientState
  805. handler:(FBDialogAppCallCompletionHandler)handler;
  806. @end