Improvements

This commit is contained in:
Hackpad
2015-08-14 12:11:45 -07:00
commit b03e832c78
3086 changed files with 531822 additions and 0 deletions

8
.gitattributes vendored Normal file
View File

@@ -0,0 +1,8 @@
.gitattributes export-ignore
.gitignore export-ignore
client export-ignore
rhino1_7R1 export-ignore
phantom export-ignore
etherpad/etc/Hackpad-APNS-beta.p12 export-ignore
etherpad/etc/Hackpad-APNS.p12 export-ignore
etherpad/etc/Hackpad-APNS-debug.p12 export-ignore

152
.gitignore vendored Normal file
View File

@@ -0,0 +1,152 @@
*~
etherpad/etc/etherpad.local.properties
etherpad/src/etherpad/collab/ace/contentcollector.js
etherpad/src/etherpad/collab/ace/domline.js
etherpad/src/etherpad/collab/ace/easysync1.js
etherpad/src/etherpad/collab/ace/easysync2.js
etherpad/src/etherpad/collab/ace/easysync2_tests.js
etherpad/src/etherpad/collab/ace/linestylefilter.js
etherpad/src/static/js/ace.js
etherpad/src/static/js/colorutils.js
etherpad/src/static/js/cssmanager_client.js
etherpad/src/static/js/domline_client.js
etherpad/src/static/js/easysync2_client.js
etherpad/src/static/js/linestylefilter_client.js
etherpad/*.log
infrastructure/lib/cos.jar
build-arch-stamp
build-indep-stamp
configure-stamp
infrastructure/lib/mysql-connector*.jar
debian/etherpad.debhelper.log
debian/etherpad.*.debhelper
debian/etherpad.substvars
debian/etherpad
debian/files
build-stamp
infrastructure/lib/mysql-*.jar
.tags
.tags_sorted_by_file
# https://gist.github.com/3786883
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################
#####
# OS X temporary files that should never be committed
.DS_Store
*.swp
*.lock
profile
####
# Xcode temporary files that should never be committed
#
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...
*~.nib
####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"
DerivedData/
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"
build/
#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
# saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
# ..but if you're in the 1%, comment out the line "*.pbxuser"
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
####
# Xcode 4 - semi-personal settings, often included in workspaces
#
# You can safely ignore the xcuserdata files - but do NOT ignore the files next to them
#
xcuserdata
####
# XCode 4 workspaces - more detailed
#
# Workspaces are important! They are a core feature of Xcode - don't exclude them :)
#
# Workspace layout is quite spammy. For reference:
#
# (root)/
# (project-name).xcodeproj/
# project.pbxproj
# project.xcworkspace/
# contents.xcworkspacedata
# xcuserdata/
# (your name)/xcuserdatad/
# xcuserdata/
# (your name)/xcuserdatad/
#
#
#
# Xcode 4 workspaces - SHARED
#
# This is UNDOCUMENTED (google: "developer.apple.com xcshareddata" - 0 results
# But if you're going to kill personal workspaces, at least keep the shared ones...
#
#
!xcshareddata
####
# XCode 4 build-schemes
#
# PRIVATE ones are stored inside xcuserdata
!xcschemes
####
# Xcode 4 - Deprecated classes
#
# Allegedly, if you manually "deprecate" your classes, they get moved here.
#
# We're using source-control, so this is a "feature" that we do not want!
*.moved-aside
####
# UNKNOWN: recommended by others, but I can't discover what these files are
#
# ...none. Everything is now explained.
pad.sublime-project
pad.sublime-workspace
*.xccheckout

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "infrastructure/SimpleWebRTC"]
path = infrastructure/SimpleWebRTC
url = git@github.com:HenrikJoreteg/SimpleWebRTC.git

40
CONTRIBUTORS Normal file
View File

@@ -0,0 +1,40 @@
This file has been automatically created using
git log | grep Author: | sort | uniq | sed -e "s+Author: ++g" > CONTRIBUTORS
Manual annotations in braces. Email addresses might or might not be proper email addresses.
Aaron Iba <aaroniba@gmail.com>
Chris Ball <cjb@laptop.org>
Christian Geier <cg@oberon.local>
Colin Zwiebel <computercolin@etherpad.(none)>
Dan Bentley <dtbentley@gmail.com>
David Greenspan <davidgreenspan@gmail.com>
Egil Moeller <egil.moller@freecode.no>
Elliot Kroo <elliot.kroo@gmail.com>
Elliot Kroo <elliot@kroo.net>
Elliot Kroo <kroo@appjet.com>
etherpad <etherpad@localhost.(none)>
geier <github@lostpackets.de>
Han Wei <laughinghan@gmail.com>
holtzermann17 <holtzermann17@gmail.com>
Jeff Mitchell <etherpad@jefferai.org>
Jeppe Toustrup <jeppe@tenzer.dk>
Joe Corneli <holtzermann17@gmail.com>
Joe Corneli <joe@planetmath-laptop.(none)>
Joseph Corneli <jac2349@lwkm013.open.ac.uk>
Michael Forrest <michael.forrest@gmail.com>
Michael Prasuhn <mike@mikeyp.net>
Mikko Rantalainen <mikko.rantalainen@peda.net>
Mikyter <mikyter@gmail.com>
penSec.IT UG (haftungsbeschränkt) <etherpad@pensec.it>
Per Andersson <avtobiff@gmail.com>
Peter Martischka <petermartischka@googlemail.com>
Peter Martischka <pita@googlemail.com>
Peter Martischka <pita@pitapoison.de>
redhog <redhog@thalariel.(none)> (Egil Möller)
root <root@primarypad.com> (John McLear)
root <root@sp.primarypad.com> (John McLear)
Sam Freilich <sam@complexmeme.net>
Simon Bohlin <simon.bohlin@gmail.com>
Simon B @piratpartiet <simonb@redhog.org>
soh335 <sugarbabe335@gmail.com>
TechKid <mail@techkid.co.uk>

202
COPYING Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

27
INSTALL Normal file
View File

@@ -0,0 +1,27 @@
INSTALLATION INSTRUCTIONS
INSTALLING ON POSIX COMPATIBLE SYSTEMS
* Install the dependencies: Scala 2.7, Sun Java JDK 7, libmysql-java, mysql
* Edit the file bin/exports.sh (and optionally
etherpad/bin/etherpad.default) and change the paths to
match your system.
* Run bin/build.sh
* Run contrib/scripts/setup-mysql-db.sh
* Copy etherpad/etc/etherpad.localdev-default.properties to etherpad/etc/etherpad.local.properties
* Edit etherpad/etc/etherpad.local.properties and set
etherpad.superUserEmailAddresses
Example: etherpad.superUserEmailAddresses = name1@example.com,name2@example.com
topdomains
Example: topdomains = yourhostname.com,localhost
* You can now run etherpad via bin/run.sh
* If you want emoji support go to https://github.com/github/gemoji/tree/master/images/emoji/unicode
and copy the images into etherpad/src/static/img/emoji/unicode/

324
LICENSE Normal file
View File

@@ -0,0 +1,324 @@
Copyright (c) 2015 Dropbox, Inc.
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 d
istributed 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.
>>>>>>>>>>>>>>
This software builds on code released by various organizations. Their
copyright and licenses are stated below. The rest is copyright the
Etherpad Foundation contributors, listed in the CONTRIBUTORS file, and
licensed under the Apache License 2.0.
=========================================================================
Copyright of the original Google code release
This distribution includes some code written by other organizations.
The rest is Copyright 2007-2009 Google Inc. and licensed under the Apache License 2.0.
=========================================================================
>>>>>>>>>>>>>>
Apache Commons Lang
Copyright 2001-2008 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
=========================================================================
== NOTICE file corresponding to section 4(d) of the Apache License, ==
== Version 2.0, in this case for the Apache Derby distribution. ==
=========================================================================
>>>>>>>>>>>>>>
Apache Derby
Copyright 2004-2008 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
Portions of Derby were originally developed by
International Business Machines Corporation and are
licensed to the Apache Software Foundation under the
"Software Grant and Corporate Contribution License Agreement",
informally known as the "Derby CLA".
The following copyright notice(s) were affixed to portions of the code
with which this file is now or was at one time distributed
and are placed here unaltered.
(C) Copyright 1997,2004 International Business Machines Corporation. All rights reserved.
(C) Copyright IBM Corp. 2003.
The portion of the functionTests under 'nist' was originally
developed by the National Institute of Standards and Technology (NIST),
an agency of the United States Department of Commerce, and adapted by
International Business Machines Corporation in accordance with the NIST
Software Acknowledgment and Redistribution document at
http://www.itl.nist.gov/div897/ctg/sql_form.htm
>>>>>>>>>>>>>>
Apache Harmony
Copyright 2006, 2009 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Portions of Apache Harmony were originally developed by
Intel Corporation and are licensed to the Apache Software
Foundation under the "Software Grant and Corporate Contribution
License Agreement" and for which the following copyright notices
apply
(C) Copyright 2005 Intel Corporation
(C) Copyright 2005-2006 Intel Corporation
(C) Copyright 2006 Intel Corporation
>>>>>>>>>>>>>>
==============================================================
Jetty Web Container
Copyright 1995-2006 Mort Bay Consulting Pty Ltd
==============================================================
The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd
unless otherwise noted. It is licensed under the apache 2.0
license.
The javax.servlet package used by Jetty is copyright
Sun Microsystems, Inc and Apache Software Foundation. It is
distributed under the Common Development and Distribution License.
You can obtain a copy of the license at
https://glassfish.dev.java.net/public/CDDLv1.0.html.
The UnixCrypt.java code ~Implements the one way cryptography used by
Unix systems for simple password protection. Copyright 1996 Aki Yoshida,
modified April 2001 by Iris Van den Broeke, Daniel Deville.
Permission to use, copy, modify and distribute UnixCrypt
for non-commercial or commercial purposes and without fee is
granted provided that the copyright notice appears in all copies.
The default JSP implementation is provided by the Glassfish JSP engine
from project Glassfish http://glassfish.dev.java.net. Copyright 2005
Sun Microsystems, Inc. and portions Copyright Apache Software Foundation.
Some portions of the code are Copyright:
2006 Tim Vernum
1999 Jason Gilbert.
The jboss integration module contains some LGPL code.
The win32 Java Service Wrapper (v3.2.3) is Copyright (c) 1999, 2006
Tanuki Software, Inc. and 2001 Silver Egg Technology. It is
covered by an open license which is viewable at
http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/extras/win32service/LICENSE.txt
>>>>>>>>>>>>>>
Apache Sanselan
Copyright 2007-2009 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
>>>>>>>>>>>>>>
TagSoup
Copyright 2002-2008 by John Cowan
>>>>>>>>>>>>>>
dnsjava:
Copyright (c) 1999-2005, Brian Wellington
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the dnsjava project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>>>>>>>>>>>>>
jBCrypt:
Copyright (c) 2006 Damien Miller
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
>>>>>>>>>>>>>>
Scala:
Copyright (c) 2002-2009 EPFL, Lausanne, unless otherwise specified.
All rights reserved.
This software was developed by the Programming Methods Laboratory of the
Swiss Federal Institute of Technology (EPFL), Lausanne, Switzerland.
Permission to use, copy, modify, and distribute this software in source
or binary form for any purpose with or without fee is hereby granted,
provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the EPFL nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
>>>>>>>>>>>>>>
YUI Compressor:
Copyright (c) 2009, Yahoo! Inc.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Yahoo! Inc. nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission of Yahoo! Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>>>>>>>>>>>>>
jQuery
Copyright (c) 2009 John Resig, http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
>>>>>>>>>>>>>>
jQuery Pulse:
Copyright (c) 2008 James Padolsey - jp(at)qd9(dot)co.uk | http://james.padolsey.com / http://enhance.qd-creative.co.uk
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
>>>>>>>>>>>>>>
SWFObject v1.5
Copyright (c) 2007 Geoff Stearns
Licensed under the MIT License
>>>>>>>>>>>>>>
jQuery Context Menu Plugin:
Original version copyright 2008 A Beautiful Site, LLC. Modifications by AppJet, Inc. released under the same license.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
>>>>>>>>>>>>>>
c3p0
Copyright (c) 2006 Machinery for Change, Inc.
Licensed under the LGPL 2.1
>>>>>>>>>>>>>>
JCommon, JFreeChart
Copyright (c) 2007-2009 Object Refinery Limited
Licensed under the LGPL 2.1
>>>>>>>>>>>>>>
Mozilla Rhino
Licensed under the MPL 1.1, GPL 2.0 or later
>>>>>>>>>>>>>>
MySQL Connector
Licensed uder the GPL 2.0 or later with the FOSS exception
#### Emoji One Artwork
* Applies to all PNG and SVG files as well as any adaptations made.
* License: Creative Commons Attribution-ShareAlike 4.0 International
* Human Readable License: http://creativecommons.org/licenses/by-sa/4.0/
* Complete Legal Terms: http://creativecommons.org/licenses/by-sa/4.0/legalcode
#### Emoji One Non-Artwork
* Applies to the Javascript, JSON, PHP, CSS, HTML files, and everything else not covered under the artwork license above.
* License: MIT
* Complete Legal Terms: http://opensource.org/licenses/MIT

189
README.md Normal file
View File

@@ -0,0 +1,189 @@
# About Hackpad
Hackpad is a web-based realtime wiki, based on the open source EtherPad collaborative document editor.
The etherpad package is distributed under the Apache License, Version 2.0.
All other packages are redistributed under their original license terms. See below for a license summary of redistributed software. More comprehensive license information can be found in the documentation of each package.
This document contains licensing information relating to the use of free and open-source software (FOSS) with or within the Hackpad software. The authors, licensors, and distributors of the FOSS disclaim all express or implied conditions, representations, and warranties relating to the FOSS and any liability arising from use and distribution of the FOSS.
This document identifies the FOSS packages used in the Hackpad software, the FOSS licenses that Dropbox believes govern those FOSS packages. While Dropbox has sought to provide complete and accurate licensing information for each FOSS package, Dropbox does not represent or warrant that the licensing information provided herein is correct or error-free. Recipients of the Hackpad software should investigate the identified FOSS packages to confirm the accuracy of the licensing information provided herein. Recipients are also encouraged to notify Dropbox of any inaccurate information or errors found in these notices.
————————————————————————
* Apache License, Version 2.0 *
solr
http://lucene.apache.org/solr/
smack api
http://www.igniterealtime.org/projects/smack/
gdata java client
https://code.google.com/p/gdata-java-client/
FacebookSDK.framework
https://developers.facebook.com/docs/ios/
GoogleToolbox
https://code.google.com/p/google-toolbox-for-mac/
OCMock
https://github.com/erikdoe/ocmock/blob/master/Source/License.txt
* MIT and MIT-Style Licenses *
bililiteRange.js
https://github.com/dwachss/bililiteRange
handlebars.js
https://github.com/wycats/handlebars.js/blob/master/LICENSE
html5shiv
https://code.google.com/p/html5shiv/
i18next
http://i18next.com/
JQuery
http://jquery.com/
JQueryUI
http://jqueryui.com/
jquery.ajaxqueue.js
http://www.onemoretake.com/2009/10/11/ajaxqueue-and-jquery-1-3/
jquery.autocomplete.js
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
jquery.ba-dotimeout.min.js
http://benalman.com/projects/jquery-dotimeout-plugin/
jquery.color.js
https://github.com/jquery/jquery-color
jquery.contextMenu.js
https://github.com/medialize/jQuery-contextMenu
jquery.customSelect.js
https://github.com/adamcoulombe/jquery.customSelect
jquery.embedly.js
https://github.com/embedly/embedly-jquery
jquery.handsontable.js
http://handsontable.com/
jquery.placeholder.js
https://github.com/mathiasbynens/jquery-placeholder
jquery.sendkeys.js
https://github.com/dwachss/bililiteRange
jquery.tablesorter.js
http://tablesorter.com/docs/
jquery.textcomplete.min.js
https://github.com/yuku-t/jquery-textcomplete/
jquery.tinysort.js
http://tinysort.sjeiti.com/
jquery.ui.position.js
http://jqueryui.com/
jquery.ui.touch-punch.min.js
http://touchpunch.furf.com/
jquery.validate.js
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
jquery.transition.js
https://github.com/louisremi/jquery.transition.js/
less-1.4.1.min.js
http://www.lesscss.org/
LESS Hat
http://LESSHat.com/
pagedown
https://code.google.com/p/pagedown/source/browse/LICENSE.txt
require.js
http://github.com/jrburke/requirejs
selectivizr-min.js
http://selectivizr.com/
simplewebrtc.bundle.js
https://github.com/HenrikJoreteg/SimpleWebRTC
socket.io.js
https://github.com/LearnBoost/socket.io-client
ACE Syntax Highlighter (tokenizer.js)
http://ace.c9.io/
to-markdown
https://github.com/domchristie/to-markdown
unicode.js
http://xregexp.com
MBProgressHUD
https://github.com/jdg/MBProgressHUD
WebViewJavascriptBridge
https://github.com/marcuswestin/WebViewJavascriptBridge/blob/master/LICENSE
JavaScript Pretty Date
http://ejohn.org/blog/javascript-pretty-date/
JSON Framework
https://code.google.com/p/json-framework/
Emoji One Non-Artwork
https://github.com/Ranks/emojione
ZeroClipboard
https://github.com/zeroclipboard/zeroclipboard
* BSD and BSD-Style Licenses *
java-apns
https://github.com/notnoop/java-apns
glue sprite generator
https://github.com/jorgebastida/glue
NSAttributedString+DDHTML
https://github.com/dbowen/NSAttributedString-DDHTML/
RNCachingURLProtocol
https://github.com/rnapier/RNCachingURLProtocol
Sente Testing Kit
http://www.quantum-step.com/download/sources/mystep/OCUnit/SourceCode/SenTestingKit/OpenSourceLicense.html
ASIHTTPRequest
http://allseeing-i.com/ASIHTTPRequest/
* Other Licenses *
jquery.autoresize.js
https://github.com/warpech/jQuery.fn.autoResize
vocaro.com UIImage Resize
https://gist.github.com/benilovj/2009030
Emoji One Artwork
https://github.com/Ranks/emojione

30
bin/build.sh Executable file
View File

@@ -0,0 +1,30 @@
#! /bin/bash
################################################################################
#
# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
# http://www.pensec.it
# mail@pensec.it
# Copyright (c) 2010 Egil Möller <egil.moller@piratpartiet.se>
#
# 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.
#
################################################################################
ETHERPADDIR="$(cd "$(dirname "$0")/.."; pwd)"
source "$ETHERPADDIR/bin/exports.sh"
# Rebuild jar
( cd "$ETHERPADDIR"/infrastructure; ./bin/makejar.sh; )
cp "$ETHERPADDIR"/infrastructure/build/appjet.jar $ETHERPADDIR/etherpad/appjet-eth-dev.jar
rm -rf "$ETHERPADDIR"/infrastructure/{appjet,build,buildjs,buildcache}

61
bin/exports.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
################################################################################
#
# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
# http://www.pensec.it
# mail@pensec.it
# Copyright (c) 2010 Egil Möller <egil.moller@piratpartiet.se>
#
# 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.
#
################################################################################
#####
# You have to change following lines to your requirements:
#
[ -e "/usr/lib/jvm/java-6-openjdk" ] && export JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
[ -e "/usr/lib/jvm/java-6-sun" ] && export JAVA_HOME="/usr/lib/jvm/java-6-sun"
[ -e "/opt/java/64/jre1.6.0_31" ] && export JAVA_HOME="/opt/java/64/jre1.6.0_31"
export SCALA_HOME="/usr/share/java"
export SCALA_LIBRARY_JAR="$PWD/lib/scala-library.jar"
export MYSQL_CONNECTOR_JAR="$PWD/lib/mysql-connector-java-5.1.34-bin.jar"
[ -e "/usr/lib/jvm/java-6-openjdk" ] && export JAVA_OPTS="-Xbootclasspath/p:../infrastructure/lib/rhino-js-1.7r3.jar:/usr/share/java/scala-library.jar"
export JAVA="/usr/bin/java"
export SCALA="/usr/bin/scala"
export PATH="$JAVA_HOME/bin:$PATH"
if ! [ -e "$MYSQL_CONNECTOR_JAR" ]; then
echo "MySql Connector jar '$MYSQL_CONNECTOR_JAR' not found - Download it here: http://dev.mysql.com/downloads/connector/j/3.1.html"
exit 1
fi
if ! [ -e "$SCALA_LIBRARY_JAR" ]; then
echo "Scala Library cannot be found '$SCALA_LIBRARY_JAR' not found - Download it here: http://www.scala-lang.org/"
exit 1
fi
if ! [ -e "$JAVA" ]; then
echo "Java cannot be found '$JAVA' not found - Download it here: http://openjdk.java.net/"
exit 1
fi
#if ! [ -e "$SCALA" ]; then
# echo "Java cannot be found '$SCALA' not found - Download it here: http://www.scala-lang.org/"
# exit 1
#fi

77
bin/hpush Executable file
View File

@@ -0,0 +1,77 @@
#!/bin/bash
REPO_ROOT=$(git rev-parse --show-toplevel)
# List all the machine if no destination specified
if [ "$#" -eq 0 ]; then
cat $REPO_ROOT/contrib/ssh_config | grep -v "User " | grep -v IdentityFile
echo
echo "$0 destination [branch(default is master)] [-f]"
echo
exit
fi
# Grep for the host, user and key to use
host=`grep -A 1 ".*Host\\s\+$1$" $REPO_ROOT/contrib/ssh_config | grep HostName | awk '{print $2}'`
identity=`grep -A 4 ".*Host\\s\+$1$" $REPO_ROOT/contrib/ssh_config | grep Identity| awk '{print $2}'`
user=`grep -A 4 ".*Host\\s\+$1$" $REPO_ROOT/contrib/ssh_config | grep User | awk '{print $2}'`
eval identity_absolute=$identity
# Load the key
ssh-add $identity_absolute > /dev/null 2>&1
# Announce what we're doing - give a grace period
echo "Pushing ${2:-master} to $1"
for i in `seq 1 5`; do
printf .
sleep 1
done
echo
# Ensure we're on the branch we say we want pushed
git branch | grep "* ${2:-master}" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo
echo "You're asking to push ${2:-master} but you have a different branch checked out!"
echo
exit
fi
# Ensure we're in sync with origin (hpush destination master -f) to override
if [ "$3" != "-f" ]; then
git push origin ${2:-master}
if [ $? -ne 0 ]; then
echo
echo "Oops. Please push to origin first!"
echo
exit
fi
fi
# Manually handle pushing to nginx
if [ "$1" == "nginx" ]; then
# backup old config
scp $user@$host:~/pad/contrib/nginx.conf /tmp/nginx.conf.old
# push new config
echo scp $REPO_ROOT/contrib/nginx.conf $user@$host:/etc/nginx/nginx.conf
scp $REPO_ROOT/contrib/nginx.conf $user@$host:~/pad/contrib/nginx.conf
# push error pages
hssh nginx mkdir -p /home/ubuntu/pad/etherpad/src/static
scp $REPO_ROOT/etherpad/src/static/502.html $user@$host:~/pad/etherpad/src/static/
# confirm the diff
echo "Configuration pushed to nginx. Saved old config to /tmp/nginx.conf.old. Diff is:"
diff /tmp/nginx.conf.old $REPO_ROOT/contrib/nginx.conf
echo "Don't forget to reload the config (sudo nginx -s reload)"
echo "Also -- make sure the configuration is the same between the Hackpad and Composer repos!"
exit
fi
# Push
git push ${3} ssh://$user@$host/home/$user/pad ${2:-master}
if [ $? -ne 0 ]; then
exit
fi

9
bin/hssh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$#" -le 0 ]; then
cat $DIR/../contrib/ssh_config
exit
fi
ssh -F $DIR/../contrib/ssh_config $@

35
bin/run.sh Executable file
View File

@@ -0,0 +1,35 @@
#! /bin/bash
################################################################################
#
# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
# http://www.pensec.it
# mail@pensec.it
# Copyright (c) 2010 Egil Möller <egil.moller@piratpartiet.se>
# Copyright (c) 2010 Mikko Rantalainen <mikko.rantalainen@peda.net>
#
# 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.
#
################################################################################
ETHERPADDIR="$(cd "$(dirname "$0")/.."; pwd)"
source "$ETHERPADDIR/bin/exports.sh"
source "$ETHERPADDIR/bin/ooffice.sh"
PID_FILE="${ETHERPADDIR}/etherpad/data/etherpad.pid"
echo $$ > $PID_FILE
cd "$ETHERPADDIR/etherpad"
# the argument here is the maximum amount of RAM to allocate
exec bin/run-local.sh "$@" --etherpad.soffice="$SOFFICE_BIN" 256M

48
bin/stop.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
# requires bash 3
TEST_STRING=java
###
# Test if the etherpad instance is alive by checking for
# the process in etherpad/data/etherpad.pid
#
# Use that PID to see if there are any processes running
# and if the command of that process matches $TEST_STRING
#
# If it matches kill the $PID,
# wait and see if the process ended.
#
# Exits 0 on success, 1 on failure
ETHERPADDIR="$(cd "$(dirname "$0")/.."; pwd)"
PID_FILE="${ETHERPADDIR}/etherpad/data/etherpad.pid"
PID=`cat ${PID_FILE}`
RUNNING_CMD="ps -o pid,ruser,ucmd --no-headers -p ${PID}"
function check_if_alive_by_pid {
result=`ps -o pid,ruser,ucmd --no-headers -p ${1}`
if [[ "${result}" =~ "${TEST_STRING}" ]] ; then
return 0
else
return 1
fi
}
i=0
while [ $i -le 10 ] ; do
check_if_alive_by_pid $PID
if [[ $? -eq 0 ]] ; then
kill -9 $PID
sleep 5
else
exit 0
fi
i=$(( $i + 1 ))
done
# Should only get here if we've tried restarting the
# Etherpad process 10 times unsuccessfully
exit 1

View File

@@ -0,0 +1,74 @@
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2010 Apple Inc. All Rights Reserved.
*/
#import <UIKit/UIKit.h>
/*
The KeychainItemWrapper class is an abstraction layer for the iPhone Keychain communication. It is merely a
simple wrapper to provide a distinct barrier between all the idiosyncracies involved with the Keychain
CF/NS container objects.
*/
@interface KeychainItemWrapper : NSObject
{
NSMutableDictionary *keychainItemData; // The actual keychain item data backing store.
NSMutableDictionary *genericPasswordQuery; // A placeholder for the generic keychain item query used to locate the item.
}
@property (nonatomic, retain) NSMutableDictionary *keychainItemData;
@property (nonatomic, retain) NSMutableDictionary *genericPasswordQuery;
// Designated initializer.
- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup;
- (void)setObject:(id)inObject forKey:(id)key;
- (id)objectForKey:(id)key;
// Initializes and resets the default generic keychain item data.
- (void)resetKeychainItem;
@end

View File

@@ -0,0 +1,313 @@
/*
File: KeychainItemWrapper.m
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2010 Apple Inc. All Rights Reserved.
*/
#import "KeychainItemWrapper.h"
#import <Security/Security.h>
/*
These are the default constants and their respective types,
available for the kSecClassGenericPassword Keychain Item class:
kSecAttrAccessGroup - CFStringRef
kSecAttrCreationDate - CFDateRef
kSecAttrModificationDate - CFDateRef
kSecAttrDescription - CFStringRef
kSecAttrComment - CFStringRef
kSecAttrCreator - CFNumberRef
kSecAttrType - CFNumberRef
kSecAttrLabel - CFStringRef
kSecAttrIsInvisible - CFBooleanRef
kSecAttrIsNegative - CFBooleanRef
kSecAttrAccount - CFStringRef
kSecAttrService - CFStringRef
kSecAttrGeneric - CFDataRef
See the header file Security/SecItem.h for more details.
*/
@interface KeychainItemWrapper (PrivateMethods)
/*
The decision behind the following two methods (secItemFormatToDictionary and dictionaryToSecItemFormat) was
to encapsulate the transition between what the detail view controller was expecting (NSString *) and what the
Keychain API expects as a validly constructed container class.
*/
- (NSMutableDictionary *)secItemFormatToDictionary:(NSDictionary *)dictionaryToConvert;
- (NSMutableDictionary *)dictionaryToSecItemFormat:(NSDictionary *)dictionaryToConvert;
// Updates the item in the keychain, or adds it if it doesn't exist.
- (void)writeToKeychain;
@end
@implementation KeychainItemWrapper
@synthesize keychainItemData, genericPasswordQuery;
- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup;
{
if (self = [super init])
{
// Begin Keychain search setup. The genericPasswordQuery leverages the special user
// defined attribute kSecAttrGeneric to distinguish itself between other generic Keychain
// items which may be included by the same application.
genericPasswordQuery = [[NSMutableDictionary alloc] init];
[genericPasswordQuery setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
[genericPasswordQuery setObject:identifier forKey:(id)kSecAttrGeneric];
// The keychain access group attribute determines if this item can be shared
// amongst multiple apps whose code signing entitlements contain the same keychain access group.
if (accessGroup != nil)
{
#if TARGET_IPHONE_SIMULATOR
// Ignore the access group if running on the iPhone simulator.
//
// Apps that are built for the simulator aren't signed, so there's no keychain access group
// for the simulator to check. This means that all apps can see all keychain items when run
// on the simulator.
//
// If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the
// simulator will return -25243 (errSecNoAccessForItem).
#else
[genericPasswordQuery setObject:accessGroup forKey:(id)kSecAttrAccessGroup];
#endif
}
// Use the proper search constants, return only the attributes of the first match.
[genericPasswordQuery setObject:(id)kSecMatchLimitOne forKey:(id)kSecMatchLimit];
[genericPasswordQuery setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnAttributes];
NSDictionary *tempQuery = [NSDictionary dictionaryWithDictionary:genericPasswordQuery];
NSMutableDictionary *outDictionary = nil;
if (! SecItemCopyMatching((CFDictionaryRef)tempQuery, (CFTypeRef *)&outDictionary) == noErr)
{
// Stick these default values into keychain item if nothing found.
[self resetKeychainItem];
// Add the generic attribute and the keychain access group.
[keychainItemData setObject:identifier forKey:(id)kSecAttrGeneric];
if (accessGroup != nil)
{
#if TARGET_IPHONE_SIMULATOR
// Ignore the access group if running on the iPhone simulator.
//
// Apps that are built for the simulator aren't signed, so there's no keychain access group
// for the simulator to check. This means that all apps can see all keychain items when run
// on the simulator.
//
// If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the
// simulator will return -25243 (errSecNoAccessForItem).
#else
[keychainItemData setObject:accessGroup forKey:(id)kSecAttrAccessGroup];
#endif
}
}
else
{
// load the saved data from Keychain.
self.keychainItemData = [self secItemFormatToDictionary:outDictionary];
}
[outDictionary release];
}
return self;
}
- (void)dealloc
{
[keychainItemData release];
[genericPasswordQuery release];
[super dealloc];
}
- (void)setObject:(id)inObject forKey:(id)key
{
if (inObject == nil) return;
id currentObject = [keychainItemData objectForKey:key];
if (![currentObject isEqual:inObject])
{
[keychainItemData setObject:inObject forKey:key];
[self writeToKeychain];
}
}
- (id)objectForKey:(id)key
{
return [keychainItemData objectForKey:key];
}
- (void)resetKeychainItem
{
OSStatus junk = noErr;
if (!keychainItemData)
{
keychainItemData = [[NSMutableDictionary alloc] init];
}
else if (keychainItemData)
{
NSMutableDictionary *tempDictionary = [self dictionaryToSecItemFormat:keychainItemData];
junk = SecItemDelete((CFDictionaryRef)tempDictionary);
NSAssert( junk == noErr || junk == errSecItemNotFound, @"Problem deleting current dictionary." );
}
// Default attributes for keychain item.
[keychainItemData setObject:@"" forKey:(id)kSecAttrAccount];
[keychainItemData setObject:@"" forKey:(id)kSecAttrLabel];
[keychainItemData setObject:@"" forKey:(id)kSecAttrDescription];
// Default data for keychain item.
[keychainItemData setObject:@"" forKey:(id)kSecValueData];
}
- (NSMutableDictionary *)dictionaryToSecItemFormat:(NSDictionary *)dictionaryToConvert
{
// The assumption is that this method will be called with a properly populated dictionary
// containing all the right key/value pairs for a SecItem.
// Create a dictionary to return populated with the attributes and data.
NSMutableDictionary *returnDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionaryToConvert];
// Add the Generic Password keychain item class attribute.
[returnDictionary setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
// Convert the NSString to NSData to meet the requirements for the value type kSecValueData.
// This is where to store sensitive data that should be encrypted.
NSString *passwordString = [dictionaryToConvert objectForKey:(id)kSecValueData];
[returnDictionary setObject:[passwordString dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecValueData];
return returnDictionary;
}
- (NSMutableDictionary *)secItemFormatToDictionary:(NSDictionary *)dictionaryToConvert
{
// The assumption is that this method will be called with a properly populated dictionary
// containing all the right key/value pairs for the UI element.
// Create a dictionary to return populated with the attributes and data.
NSMutableDictionary *returnDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionaryToConvert];
// Add the proper search key and class attribute.
[returnDictionary setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData];
[returnDictionary setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
// Acquire the password data from the attributes.
NSData *passwordData = NULL;
if (SecItemCopyMatching((CFDictionaryRef)returnDictionary, (CFTypeRef *)&passwordData) == noErr)
{
// Remove the search, class, and identifier key/value, we don't need them anymore.
[returnDictionary removeObjectForKey:(id)kSecReturnData];
// Add the password to the dictionary, converting from NSData to NSString.
NSString *password = [[[NSString alloc] initWithBytes:[passwordData bytes] length:[passwordData length]
encoding:NSUTF8StringEncoding] autorelease];
[returnDictionary setObject:password forKey:(id)kSecValueData];
}
else
{
// Don't do anything if nothing is found.
NSAssert(NO, @"Serious error, no matching item found in the keychain.\n");
}
[passwordData release];
return returnDictionary;
}
- (void)writeToKeychain
{
NSDictionary *attributes = NULL;
NSMutableDictionary *updateItem = NULL;
OSStatus result;
if (SecItemCopyMatching((CFDictionaryRef)genericPasswordQuery, (CFTypeRef *)&attributes) == noErr)
{
// First we need the attributes from the Keychain.
updateItem = [NSMutableDictionary dictionaryWithDictionary:attributes];
// Second we need to add the appropriate search key/values.
[updateItem setObject:[genericPasswordQuery objectForKey:(id)kSecClass] forKey:(id)kSecClass];
// Lastly, we need to set up the updated attribute list being careful to remove the class.
NSMutableDictionary *tempCheck = [self dictionaryToSecItemFormat:keychainItemData];
[tempCheck removeObjectForKey:(id)kSecClass];
#if TARGET_IPHONE_SIMULATOR
// Remove the access group if running on the iPhone simulator.
//
// Apps that are built for the simulator aren't signed, so there's no keychain access group
// for the simulator to check. This means that all apps can see all keychain items when run
// on the simulator.
//
// If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the
// simulator will return -25243 (errSecNoAccessForItem).
//
// The access group attribute will be included in items returned by SecItemCopyMatching,
// which is why we need to remove it before updating the item.
[tempCheck removeObjectForKey:(id)kSecAttrAccessGroup];
#endif
// An implicit assumption is that you can only update a single item at a time.
result = SecItemUpdate((CFDictionaryRef)updateItem, (CFDictionaryRef)tempCheck);
NSAssert( result == noErr, @"Couldn't update the Keychain Item." );
}
else
{
// No previous item found; add the new one.
result = SecItemAdd((CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL);
NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
}
}
@end

View File

@@ -0,0 +1,104 @@
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 3.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2013 Apple Inc. All Rights Reserved.
*/
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>
typedef enum : NSInteger {
NotReachable = 0,
ReachableViaWiFi,
ReachableViaWWAN
} NetworkStatus;
extern NSString *kReachabilityChangedNotification;
@interface Reachability : NSObject
{
BOOL localWiFiRef;
SCNetworkReachabilityRef reachabilityRef;
}
/*!
* Use to check the reachability of a given host name.
*/
+ (instancetype)reachabilityWithHostName:(NSString *)hostName;
/*!
* Use to check the reachability of a given IP address.
*/
+ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
/*!
* Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
*/
+ (instancetype)reachabilityForInternetConnection;
/*!
* Checks whether a local WiFi connection is available.
*/
+ (instancetype)reachabilityForLocalWiFi;
/*!
* Start listening for reachability notifications on the current run loop.
*/
- (BOOL)startNotifier;
- (void)stopNotifier;
- (NetworkStatus)currentReachabilityStatus;
/*!
* WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
*/
- (BOOL)connectionRequired;
@end

View File

@@ -0,0 +1,307 @@
/*
File: Reachability.m
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 3.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2013 Apple Inc. All Rights Reserved.
*/
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
#import <sys/socket.h>
#import <CoreFoundation/CoreFoundation.h>
#import "Reachability.h"
NSString *kReachabilityChangedNotification = @"kNetworkReachabilityChangedNotification";
#pragma mark - Supporting functions
#define kShouldPrintReachabilityFlags 0
static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
{
#if kShouldPrintReachabilityFlags
NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
(flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
(flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
(flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
(flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
(flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
comment
);
#endif
}
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
{
#pragma unused (target, flags)
NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
NSCAssert([(__bridge NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
Reachability* noteObject = (__bridge Reachability *)info;
// Post a notification to notify the client that the network reachability changed.
[[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject];
}
#pragma mark - Reachability implementation
@implementation Reachability
+ (instancetype)reachabilityWithHostName:(NSString *)hostName;
{
Reachability* returnValue = NULL;
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
if (reachability != NULL)
{
returnValue= [[self alloc] init];
if (returnValue != NULL)
{
returnValue->reachabilityRef = reachability;
returnValue->localWiFiRef = NO;
}
}
return returnValue;
}
+ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
{
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)hostAddress);
Reachability* returnValue = NULL;
if (reachability != NULL)
{
returnValue = [[self alloc] init];
if (returnValue != NULL)
{
returnValue->reachabilityRef = reachability;
returnValue->localWiFiRef = NO;
}
}
return returnValue;
}
+ (instancetype)reachabilityForInternetConnection;
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
return [self reachabilityWithAddress:&zeroAddress];
}
+ (instancetype)reachabilityForLocalWiFi;
{
struct sockaddr_in localWifiAddress;
bzero(&localWifiAddress, sizeof(localWifiAddress));
localWifiAddress.sin_len = sizeof(localWifiAddress);
localWifiAddress.sin_family = AF_INET;
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0.
localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
Reachability* returnValue = [self reachabilityWithAddress: &localWifiAddress];
if (returnValue != NULL)
{
returnValue->localWiFiRef = YES;
}
return returnValue;
}
#pragma mark - Start and stop notifier
- (BOOL)startNotifier
{
BOOL returnValue = NO;
SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL};
if (SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
{
if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
{
returnValue = YES;
}
}
return returnValue;
}
- (void)stopNotifier
{
if (reachabilityRef != NULL)
{
SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
}
}
- (void)dealloc
{
[self stopNotifier];
if (reachabilityRef != NULL)
{
CFRelease(reachabilityRef);
}
}
#pragma mark - Network Flag Handling
- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
{
PrintReachabilityFlags(flags, "localWiFiStatusForFlags");
BOOL returnValue = NotReachable;
if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))
{
returnValue = ReachableViaWiFi;
}
return returnValue;
}
- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
{
PrintReachabilityFlags(flags, "networkStatusForFlags");
if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
{
// The target host is not reachable.
return NotReachable;
}
BOOL returnValue = NotReachable;
if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
{
/*
If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi...
*/
returnValue = ReachableViaWiFi;
}
if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
{
/*
... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs...
*/
if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
{
/*
... and no [user] intervention is needed...
*/
returnValue = ReachableViaWiFi;
}
}
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
{
/*
... but WWAN connections are OK if the calling application is using the CFNetwork APIs.
*/
returnValue = ReachableViaWWAN;
}
return returnValue;
}
- (BOOL)connectionRequired
{
NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
}
return NO;
}
- (NetworkStatus)currentReachabilityStatus
{
NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
NetworkStatus returnValue = NotReachable;
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
if (localWiFiRef)
{
returnValue = [self localWiFiStatusForFlags:flags];
}
else
{
returnValue = [self networkStatusForFlags:flags];
}
}
return returnValue;
}
@end

View File

@@ -0,0 +1 @@
./Versions/A/FacebookSDK

View File

@@ -0,0 +1 @@
./Versions/A/Headers

View File

@@ -0,0 +1 @@
./Versions/A/Resources

View File

@@ -0,0 +1,140 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@class FBAccessTokenData
@abstract Represents an access token used for the Facebook login flow
and includes associated metadata such as expiration date and permissions.
You should use factory methods (createToken...) to construct instances
and should be treated as immutable.
@discussion For more information, see
https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/.
*/
@interface FBAccessTokenData : NSObject <NSCopying>
/*!
@method
@abstract Creates an FBAccessTokenData from an App Link provided by the Facebook application
or nil if the url is not valid.
@param url The url provided.
@param appID needed in order to verify URL format.
@param urlSchemeSuffix needed in order to verify URL format.
*/
+ (FBAccessTokenData *) createTokenFromFacebookURL:(NSURL *)url appID:(NSString *)appID urlSchemeSuffix:(NSString *)urlSchemeSuffix;
/*!
@method
@abstract Creates an FBAccessTokenData from a dictionary or returns nil if required data is missing.
@param dictionary the dictionary with FBSessionTokenCachingStrategy keys.
*/
+ (FBAccessTokenData *) createTokenFromDictionary:(NSDictionary *)dictionary;
/*!
@method
@abstract Creates an FBAccessTokenData from existing information or returns nil if required data is missing.
@param accessToken The token string. If nil or empty, this method will return nil.
@param permissions The permissions set. A value of nil indicates basic permissions.
@param expirationDate The expiration date. A value of nil defaults to `[NSDate distantFuture]`.
@param loginType The login source of the token.
@param refreshDate The date that token was last refreshed. A value of nil defaults to `[NSDate date]`.
*/
+ (FBAccessTokenData *) createTokenFromString:(NSString *)accessToken
permissions:(NSArray *)permissions
expirationDate:(NSDate *)expirationDate
loginType:(FBSessionLoginType)loginType
refreshDate:(NSDate *)refreshDate;
/*!
@method
@abstract Creates an FBAccessTokenData from existing information or returns nil if required data is missing.
@param accessToken The token string. If nil or empty, this method will return nil.
@param permissions The permissions set. A value of nil indicates basic permissions.
@param expirationDate The expiration date. A value of nil defaults to `[NSDate distantFuture]`.
@param loginType The login source of the token.
@param refreshDate The date that token was last refreshed. A value of nil defaults to `[NSDate date]`.
@param permissionsRefreshDate The date the permissions were last refreshed. A value of nil defaults to `[NSDate distantPast]`.
*/
+ (FBAccessTokenData *) createTokenFromString:(NSString *)accessToken
permissions:(NSArray *)permissions
expirationDate:(NSDate *)expirationDate
loginType:(FBSessionLoginType)loginType
refreshDate:(NSDate *)refreshDate
permissionsRefreshDate:(NSDate *)permissionsRefreshDate;
/*!
@method
@abstract Returns a dictionary representation of this instance.
@discussion This is provided for backwards compatibility with previous
access token related APIs that used a NSDictionary (see `FBSessionTokenCachingStrategy`).
*/
- (NSMutableDictionary *) dictionary;
/*!
@method
@abstract Returns a Boolean value that indicates whether a given object is an FBAccessTokenData object and exactly equal the receiver.
@param accessTokenData the data to compare to the receiver.
*/
- (BOOL) isEqualToAccessTokenData:(FBAccessTokenData *)accessTokenData;
/*!
@abstract returns the access token NSString.
*/
@property (readonly, nonatomic, copy) NSString *accessToken;
/*!
@abstract returns the permissions associated with the access token.
*/
@property (readonly, nonatomic, copy) NSArray *permissions;
/*!
@abstract returns the expiration date of the access token.
*/
@property (readonly, nonatomic, copy) NSDate *expirationDate;
/*!
@abstract returns the login type associated with the token.
*/
@property (readonly, nonatomic) FBSessionLoginType loginType;
/*!
@abstract returns the date the token was last refreshed.
*/
@property (readonly, nonatomic, copy) NSDate *refreshDate;
/*!
@abstract returns the date the permissions were last refreshed.
*/
@property (readonly, nonatomic, copy) NSDate *permissionsRefreshDate;
@end

View File

@@ -0,0 +1,232 @@
/*
* Copyright 2010-present 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 "FBAccessTokenData.h"
#import "FBAppLinkData.h"
#import "FBDialogsData.h"
#import "FBSession.h"
@class FBAppCall;
/*!
@typedef FBAppCallHandler
@abstract
A block that is passed to performAppCall to register for a callback with the results
of that AppCall
@discussion
Pass a block of this type when calling performAppCall. This will be called on the UI
thread, once the AppCall completes.
@param call The `FBAppCall` that was completed.
*/
typedef void (^FBAppCallHandler)(FBAppCall *call);
/*!
@typedef FBAppLinkFallbackHandler
@abstract
See `+openDeferredAppLink`.
*/
typedef void (^FBAppLinkFallbackHandler)(NSError *error);
/*!
@class FBAppCall
@abstract
The FBAppCall object is used to encapsulate state when the app performs an
action that requires switching over to the native Facebook app, or when the app
receives an App Link.
@discussion
- Each FBAppCall instance will have a unique ID
- This object is passed into an FBAppCallHandler for context
- dialogData will be present if this AppCall is for a Native Dialog
- appLinkData will be present if this AppCall is for an App Link
- accessTokenData will be present if this AppCall contains an access token.
*/
@interface FBAppCall : NSObject
/*! @abstract The ID of this FBAppCall instance */
@property (nonatomic, readonly) NSString *ID;
/*! @abstract Error that occurred in processing this AppCall */
@property (nonatomic, readonly) NSError *error;
/*! @abstract Data related to a Dialog AppCall */
@property (nonatomic, readonly) FBDialogsData *dialogData;
/*! @abstract Data for native app link */
@property (nonatomic, readonly) FBAppLinkData *appLinkData;
/*! @abstract Access Token that was returned in this AppCall */
@property (nonatomic, readonly) FBAccessTokenData *accessTokenData;
/*!
@abstract
Returns an FBAppCall instance from a url, if applicable. Otherwise, returns nil.
@param url The url.
@return an FBAppCall instance if the url is valid; nil otherwise.
@discussion This is typically used for App Link URLs.
*/
+ (FBAppCall *) appCallFromURL:(NSURL *)url;
/*!
@abstract
Compares the receiving FBAppCall to the passed in FBAppCall
@param appCall the other FBAppCall to compare to.
@return YES if the AppCalls can be considered to be the same; NO if otherwise.
*/
- (BOOL)isEqualToAppCall:(FBAppCall *)appCall;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param handler Optional handler that gives the app the opportunity to do some further processing on urls
that the SDK could not completely process. A fallback handler is not a requirement for such a url to be considered
handled. The fallback handler, if specified, is only ever called sychronously, before the method returns.
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
fallbackHandler:(FBAppCallHandler)handler;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param session If this url is being sent back to this app as part of SSO authorization flow, then pass in the
session that was being opened. A nil value defaults to FBSession.activeSession
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
withSession:(FBSession *)session;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param session If this url is being sent back to this app as part of SSO authorization flow, then pass in the
session that was being opened. A nil value defaults to FBSession.activeSession
@param handler Optional handler that gives the app the opportunity to do some further processing on urls
that the SDK could not completely process. A fallback handler is not a requirement for such a url to be considered
handled. The fallback handler, if specified, is only ever called sychronously, before the method returns.
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
withSession:(FBSession *)session
fallbackHandler:(FBAppCallHandler)handler;
/*!
@abstract
Call this method when the application's applicationDidBecomeActive: is invoked.
This ensures proper state management of any pending FBAppCalls or pending login flow for the
FBSession.activeSession. If any pending FBAppCalls are found, their registered callbacks
will be invoked with appropriate state
*/
+ (void)handleDidBecomeActive;
/*!
@abstract
Call this method when the application's applicationDidBecomeActive: is invoked.
This ensures proper state management of any pending FBAppCalls or a pending open for the
passed in FBSession. If any pending FBAppCalls are found, their registered callbacks will
be invoked with appropriate state
@param session Session that is currently being used. Any pending calls to open will be cancelled.
If no session is provided, then the activeSession (if present) is used.
*/
+ (void)handleDidBecomeActiveWithSession:(FBSession *)session;
/*!
@abstract
Call this method from the main thread to fetch deferred applink data. This may require
a network round trip. If successful, [+UIApplication openURL:] is invoked with the link
data. Otherwise, the fallbackHandler will be dispatched to the main thread.
@param fallbackHandler the handler to be invoked if applink data could not be opened.
@discussion the fallbackHandler may contain an NSError instance to capture any errors. In the
common case where there simply was no app link data, the NSError instance will be nil.
This method should only be called from a location that occurs after any launching URL has
been processed (e.g., you should call this method from your application delegate's applicationDidBecomeActive:)
to avoid duplicate invocations of openURL:.
If you must call this from the delegate's didFinishLaunchingWithOptions: you should
only do so if the application is not being launched by a URL. For example,
if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) {
[FBAppCall openDeferredAppLink:^(NSError *error) {
// ....
}
}
*/
+ (void)openDeferredAppLink:(FBAppLinkFallbackHandler)fallbackHandler;
@end

View File

@@ -0,0 +1,451 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@typedef FBAppEventsFlushBehavior enum
@abstract
Control when <FBAppEvents> sends log events to the server
@discussion
*/
typedef enum {
/*! Flush automatically: periodically (once a minute or every 100 logged events) and always at app reactivation. */
FBAppEventsFlushBehaviorAuto,
/*! Only flush when the `flush` method is called. When an app is moved to background/terminated, the
events are persisted and re-established at activation, but they will only be written with an
explicit call to `flush`. */
FBAppEventsFlushBehaviorExplicitOnly,
} FBAppEventsFlushBehavior;
/*
* Constant used by NSNotificationCenter for results of flushing AppEvents event logs
*/
/*! NSNotificationCenter name indicating a result of a failed log flush attempt */
extern NSString *const FBAppEventsLoggingResultNotification;
// Predefined event names for logging events common to many apps. Logging occurs through the `logEvent` family of methods on `FBAppEvents`.
// Common event parameters are provided in the `FBAppEventsParameterNames*` constants.
// General purpose
/*! Log this event when an app is being activated, typically in the AppDelegate's applicationDidBecomeActive. */
extern NSString *const FBAppEventNameActivatedApp;
/*! Log this event when a user has completed registration with the app. */
extern NSString *const FBAppEventNameCompletedRegistration;
/*! Log this event when a user has viewed a form of content in the app. */
extern NSString *const FBAppEventNameViewedContent;
/*! Log this event when a user has performed a search within the app. */
extern NSString *const FBAppEventNameSearched;
/*! Log this event when the user has rated an item in the app. The valueToSum passed to logEvent should be the numeric rating. */
extern NSString *const FBAppEventNameRated;
/*! Log this event when the user has completed a tutorial in the app. */
extern NSString *const FBAppEventNameCompletedTutorial;
// Ecommerce related
/*! Log this event when the user has added an item to their cart. The valueToSum passed to logEvent should be the item's price. */
extern NSString *const FBAppEventNameAddedToCart;
/*! Log this event when the user has added an item to their wishlist. The valueToSum passed to logEvent should be the item's price. */
extern NSString *const FBAppEventNameAddedToWishlist;
/*! Log this event when the user has entered the checkout process. The valueToSum passed to logEvent should be the total price in the cart. */
extern NSString *const FBAppEventNameInitiatedCheckout;
/*! Log this event when the user has entered their payment info. */
extern NSString *const FBAppEventNameAddedPaymentInfo;
/*! Log this event when the user has completed a purchase. The `[FBAppEvents logPurchase]` method is a shortcut for logging this event. */
extern NSString *const FBAppEventNamePurchased;
// Gaming related
/*! Log this event when the user has achieved a level in the app. */
extern NSString *const FBAppEventNameAchievedLevel;
/*! Log this event when the user has unlocked an achievement in the app. */
extern NSString *const FBAppEventNameUnlockedAchievement;
/*! Log this event when the user has spent app credits. The valueToSum passed to logEvent should be the number of credits spent. */
extern NSString *const FBAppEventNameSpentCredits;
// Predefined event name parameters for common additional information to accompany events logged through the `logEvent` family
// of methods on `FBAppEvents`. Common event names are provided in the `FBAppEventName*` constants.
/*! Parameter key used to specify currency used with logged event. E.g. "USD", "EUR", "GBP". See ISO-4217 for specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>. */
extern NSString *const FBAppEventParameterNameCurrency;
/*! Parameter key used to specify method user has used to register for the app, e.g., "Facebook", "email", "Twitter", etc */
extern NSString *const FBAppEventParameterNameRegistrationMethod;
/*! Parameter key used to specify a generic content type/family for the logged event, e.g. "music", "photo", "video". Options to use will vary based upon what the app is all about. */
extern NSString *const FBAppEventParameterNameContentType;
/*! Parameter key used to specify an ID for the specific piece of content being logged about. Could be an EAN, article identifier, etc., depending on the nature of the app. */
extern NSString *const FBAppEventParameterNameContentID;
/*! Parameter key used to specify the string provided by the user for a search operation. */
extern NSString *const FBAppEventParameterNameSearchString;
/*! Parameter key used to specify whether the activity being logged about was successful or not. `FBAppEventParameterValueYes` and `FBAppEventParameterValueNo` are good canonical values to use for this parameter. */
extern NSString *const FBAppEventParameterNameSuccess;
/*! Parameter key used to specify the maximum rating available for the `FBAppEventNameRate` event. E.g., "5" or "10". */
extern NSString *const FBAppEventParameterNameMaxRatingValue;
/*! Parameter key used to specify whether payment info is available for the `FBAppEventNameInitiatedCheckout` event. `FBAppEventParameterValueYes` and `FBAppEventParameterValueNo` are good canonical values to use for this parameter. */
extern NSString *const FBAppEventParameterNamePaymentInfoAvailable;
/*! Parameter key used to specify how many items are being processed for an `FBAppEventNameInitiatedCheckout` or `FBAppEventNamePurchased` event. */
extern NSString *const FBAppEventParameterNameNumItems;
/*! Parameter key used to specify the level achieved in a `FBAppEventNameAchieved` event. */
extern NSString *const FBAppEventParameterNameLevel;
/*! Parameter key used to specify a description appropriate to the event being logged. E.g., the name of the achievement unlocked in the `FBAppEventNameAchievementUnlocked` event. */
extern NSString *const FBAppEventParameterNameDescription;
// Predefined values to assign to event parameters that accompany events logged through the `logEvent` family
// of methods on `FBAppEvents`. Common event parameters are provided in the `FBAppEventParameterName*` constants.
/*! Yes-valued parameter value to be used with parameter keys that need a Yes/No value */
extern NSString *const FBAppEventParameterValueYes;
/*! No-valued parameter value to be used with parameter keys that need a Yes/No value */
extern NSString *const FBAppEventParameterValueNo;
/*!
@class FBAppEvents
@abstract
Client-side event logging for specialized application analytics available through Facebook App Insights
and for use with Facebook Ads conversion tracking and optimization.
@discussion
The `FBAppEvents` static class has a few related roles:
+ Logging predefined and application-defined events to Facebook App Insights with a
numeric value to sum across a large number of events, and an optional set of key/value
parameters that define "segments" for this event (e.g., 'purchaserStatus' : 'frequent', or
'gamerLevel' : 'intermediate')
+ Logging events to later be used for ads optimization around lifetime value.
+ Methods that control the way in which events are flushed out to the Facebook servers.
Here are some important characteristics of the logging mechanism provided by `FBAppEvents`:
+ Events are not sent immediately when logged. They're cached and flushed out to the Facebook servers
in a number of situations:
- when an event count threshold is passed (currently 100 logged events).
- when a time threshold is passed (currently 60 seconds).
- when an app has gone to background and is then brought back to the foreground.
+ Events will be accumulated when the app is in a disconnected state, and sent when the connection is
restored and one of the above 'flush' conditions are met.
+ The `FBAppEvents` class in thread-safe in that events may be logged from any of the app's threads.
+ The developer can set the `flushBehavior` on `FBAppEvents` to force the flushing of events to only
occur on an explicit call to the `flush` method.
+ The developer can turn on console debug output for event logging and flushing to the server by using
the `FBLoggingBehaviorAppEvents` value in `[FBSettings setLoggingBehavior:]`.
Some things to note when logging events:
+ There is a limit on the number of unique event names an app can use, on the order of 300.
+ There is a limit to the number of unique parameter names in the provided parameters that can
be used per event, on the order of 10. This is not just for an individual call, but for all
invocations for that eventName.
+ Event names and parameter names (the keys in the NSDictionary) must be between 2 and 40 characters, and
must consist of alphanumeric characters, _, -, or spaces.
+ The length of each parameter value can be no more than on the order of 100 characters.
*/
@interface FBAppEvents : NSObject
/*
* Basic event logging
*/
/*!
@method
@abstract
Log an event with just an eventName.
@param eventName The name of the event to record. Limitations on number of events and name length
are given in the `FBAppEvents` documentation.
*/
+ (void)logEvent:(NSString *)eventName;
/*!
@method
@abstract
Log an event with an eventName and a numeric value to be aggregated with other events of this name.
@param eventName The name of the event to record. Limitations on number of events and name length
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
the cumulative and average value of this amount.
*/
+ (void)logEvent:(NSString *)eventName
valueToSum:(double)valueToSum;
/*!
@method
@abstract
Log an event with an eventName and a set of key/value pairs in the parameters dictionary.
Parameter limitations are described above.
@param eventName The name of the event to record. Limitations on number of events and name construction
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
*/
+ (void)logEvent:(NSString *)eventName
parameters:(NSDictionary *)parameters;
/*!
@method
@abstract
Log an event with an eventName, a numeric value to be aggregated with other events of this name,
and a set of key/value pairs in the parameters dictionary.
@param eventName The name of the event to record. Limitations on number of events and name construction
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
the cumulative and average value of this amount.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
*/
+ (void)logEvent:(NSString *)eventName
valueToSum:(double)valueToSum
parameters:(NSDictionary *)parameters;
/*!
@method
@abstract
Log an event with an eventName, a numeric value to be aggregated with other events of this name,
and a set of key/value pairs in the parameters dictionary. Providing session lets the developer
target a particular <FBSession>. If nil is provided, then `[FBSession activeSession]` will be used.
@param eventName The name of the event to record. Limitations on number of events and name construction
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
the cumulative and average value of this amount. Note that this is an NSNumber, and a value of `nil` denotes
that this event doesn't have a value associated with it for summation.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
@param session <FBSession> to direct the event logging to, and thus be logged with whatever user (if any)
is associated with that <FBSession>.
*/
+ (void)logEvent:(NSString *)eventName
valueToSum:(NSNumber *)valueToSum
parameters:(NSDictionary *)parameters
session:(FBSession *)session;
/*
* Purchase logging
*/
/*!
@method
@abstract
Log a purchase of the specified amount, in the specified currency.
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency. This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
@discussion This event immediately triggers a flush of the `FBAppEvents` event queue, unless the `flushBehavior` is set
to `FBAppEventsFlushBehaviorExplicitOnly`.
*/
+ (void)logPurchase:(double)purchaseAmount
currency:(NSString *)currency;
/*!
@method
@abstract
Log a purchase of the specified amount, in the specified currency, also providing a set of
additional characteristics describing the purchase.
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency.This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
@discussion This event immediately triggers a flush of the `FBAppEvents` event queue, unless the `flushBehavior` is set
to `FBAppEventsFlushBehaviorExplicitOnly`.
*/
+ (void)logPurchase:(double)purchaseAmount
currency:(NSString *)currency
parameters:(NSDictionary *)parameters;
/*!
@method
@abstract
Log a purchase of the specified amount, in the specified currency, also providing a set of
additional characteristics describing the purchase, as well as an <FBSession> to log to.
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency.This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
@param session <FBSession> to direct the event logging to, and thus be logged with whatever user (if any)
is associated with that <FBSession>. A value of `nil` will use `[FBSession activeSession]`.
@discussion This event immediately triggers a flush of the `FBAppEvents` event queue, unless the `flushBehavior` is set
to `FBAppEventsFlushBehaviorExplicitOnly`.
*/
+ (void)logPurchase:(double)purchaseAmount
currency:(NSString *)currency
parameters:(NSDictionary *)parameters
session:(FBSession *)session;
/*!
@method
@abstract This method has been replaced by [FBSettings limitEventAndDataUsage] */
+ (BOOL)limitEventUsage __attribute__ ((deprecated("use [FBSettings limitEventAndDataUsage] instead")));
/*!
@method
@abstract This method has been replaced by [FBSettings setLimitEventUsage] */
+ (void)setLimitEventUsage:(BOOL)limitEventUsage __attribute__ ((deprecated("use [FBSettings setLimitEventAndDataUsage] instead")));
/*!
@method
@abstract
Notifies the events system that the app has launched & logs an activatedApp event. Should typically be placed in the app delegates' `applicationDidBecomeActive:` method.
*/
+ (void)activateApp;
/*
* Control over event batching/flushing
*/
/*!
@method
@abstract
Get the current event flushing behavior specifying when events are sent back to Facebook servers.
*/
+ (FBAppEventsFlushBehavior)flushBehavior;
/*!
@method
@abstract
Set the current event flushing behavior specifying when events are sent back to Facebook servers.
@param flushBehavior The desired `FBAppEventsFlushBehavior` to be used.
*/
+ (void)setFlushBehavior:(FBAppEventsFlushBehavior)flushBehavior;
/*!
@method
@abstract
Explicitly kick off flushing of events to Facebook. This is an asynchronous method, but it does initiate an immediate
kick off. Server failures will be reported through the NotificationCenter with notification ID `FBAppEventsLoggingResultNotification`.
*/
+ (void)flush;
@end

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2010-present 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>
/*!
@abstract This class contains information that represents an App Link from Facebook.
*/
@interface FBAppLinkData : NSObject
/*! @abstract The target */
@property (readonly) NSURL *targetURL;
/*! @abstract List of the types of actions for this target */
@property (readonly) NSArray *actionTypes;
/*! @abstract List of the ids of the actions for this target */
@property (readonly) NSArray *actionIDs;
/*! @abstract Reference breadcrumb provided during creation of story */
@property (readonly) NSString *ref;
/*! @abstract User Agent string set by the referer */
@property (readonly) NSString *userAgent;
/*! @abstract Referer data is a JSON object set by the referer with referer-specific content */
@property (readonly) NSDictionary *refererData;
/*! @abstract Full set of query parameters for this app link */
@property (readonly) NSDictionary *originalQueryParameters;
/*! @abstract Original url from which applinkData was extracted */
@property (readonly) NSURL *originalURL;
/*! @abstract Addtional arguments supplied with the App Link data. */
@property (readonly) NSDictionary *arguments;
@end

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@class
@abstract
Base class from which CacheDescriptors derive, provides a method to fetch data for later use
@discussion
Cache descriptors allow your application to specify the arguments that will be
later used with another object, such as the FBFriendPickerViewController. By using a cache descriptor
instance, an application can choose to fetch data ahead of the point in time where the data is needed.
*/
@interface FBCacheDescriptor : NSObject
/*!
@method
@abstract
Fetches and caches the data described by the cache descriptor instance, for the given session.
@param session the <FBSession> to use for fetching data
*/
- (void)prefetchAndCacheForSession:(FBSession*)session;
@end

View File

@@ -0,0 +1,21 @@
/*
* Copyright 2010-present 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 "FBDialog.h"
#include "FBLoginDialog.h"
#include "FBRequest.h"
#include "Facebook.h"

View File

@@ -0,0 +1,165 @@
/*
* Copyright 2010-present 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;
@class FBFrictionlessRequestSettings;
/**
* 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;
UIButton* _closeButton;
UIInterfaceOrientation _orientation;
BOOL _showingKeyboard;
BOOL _isViewInvisible;
FBFrictionlessRequestSettings* _frictionlessSettings;
// 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;
- (NSString *) getStringFromUrl: (NSString*) url needle:(NSString *) needle;
- (id)initWithURL: (NSString *) loadingURL
params: (NSMutableDictionary *) params
isViewInvisible: (BOOL) isViewInvisible
frictionlessSettings: (FBFrictionlessRequestSettings *) frictionlessSettings
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 File

@@ -0,0 +1,492 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "FBAppCall.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBShareDialogParams.h"
@class FBSession;
@protocol FBOpenGraphAction;
/*!
@typedef FBNativeDialogResult enum
@abstract
Passed to a handler to indicate the result of a dialog being displayed to the user.
*/
typedef enum {
/*! Indicates that the dialog action completed successfully. */
FBOSIntegratedShareDialogResultSucceeded = 0,
/*! Indicates that the dialog action was cancelled (either by the user or the system). */
FBOSIntegratedShareDialogResultCancelled = 1,
/*! Indicates that the dialog could not be shown (because not on ios6 or ios6 auth was not used). */
FBOSIntegratedShareDialogResultError = 2
} FBOSIntegratedShareDialogResult;
/*!
@typedef
@abstract Defines a handler that will be called in response to the native share dialog
being displayed.
*/
typedef void (^FBOSIntegratedShareDialogHandler)(FBOSIntegratedShareDialogResult result, NSError *error);
/*!
@typedef FBDialogAppCallCompletionHandler
@abstract
A block that when passed to a method in FBDialogs is called back
with the results of the AppCall for that dialog.
@discussion
This will be called on the UI thread, once the AppCall completes.
@param call The `FBAppCall` that was completed.
@param results The results of the AppCall for the dialog. This parameters is present
purely for convenience, and is the exact same value as call.dialogData.results.
@param error The `NSError` representing any error that occurred. This parameters is
present purely for convenience, and is the exact same value as call.error.
*/
typedef void (^FBDialogAppCallCompletionHandler)(
FBAppCall *call,
NSDictionary *results,
NSError *error);
/*!
@class FBDialogs
@abstract
Provides methods to display native (i.e., non-Web-based) dialogs to the user.
@discussion
If you are building an app with a urlSchemeSuffix, you should also set the appropriate
plist entry. See `[FBSettings defaultUrlSchemeSuffix]`.
*/
@interface FBDialogs : NSObject
/*!
@abstract
Presents a dialog that allows the user to share a status update that may include
text, images, or URLs. This dialog is only available on iOS 6.0 and above. The
current active session returned by [FBSession activeSession] will be used to determine
whether the dialog will be displayed. If a session is active, it must be open and the
login method used to authenticate the user must be native iOS 6.0 authentication.
If no session active, then whether the call succeeds or not will depend on
whether Facebook integration has been configured.
@param viewController The view controller which will present the dialog.
@param initialText The text which will initially be populated in the dialog. The user
will have the opportunity to edit this text before posting it. May be nil.
@param image A UIImage that will be attached to the status update. May be nil.
@param url An NSURL that will be attached to the status update. May be nil.
@param handler A handler that will be called when the dialog is dismissed, or if an error
occurs. May be nil.
@return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
will still be called, with an error indicating the reason the dialog was not displayed)
*/
+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
image:(UIImage*)image
url:(NSURL*)url
handler:(FBOSIntegratedShareDialogHandler)handler;
/*!
@abstract
Presents a dialog that allows the user to share a status update that may include
text, images, or URLs. This dialog is only available on iOS 6.0 and above. The
current active session returned by [FBSession activeSession] will be used to determine
whether the dialog will be displayed. If a session is active, it must be open and the
login method used to authenticate the user must be native iOS 6.0 authentication.
If no session active, then whether the call succeeds or not will depend on
whether Facebook integration has been configured.
@param viewController The view controller which will present the dialog.
@param initialText The text which will initially be populated in the dialog. The user
will have the opportunity to edit this text before posting it. May be nil.
@param images An array of UIImages that will be attached to the status update. May
be nil.
@param urls An array of NSURLs that will be attached to the status update. May be nil.
@param handler A handler that will be called when the dialog is dismissed, or if an error
occurs. May be nil.
@return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
will still be called, with an error indicating the reason the dialog was not displayed)
*/
+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBOSIntegratedShareDialogHandler)handler;
/*!
@abstract
Presents a dialog that allows the user to share a status update that may include
text, images, or URLs. This dialog is only available on iOS 6.0 and above. An
<FBSession> may be specified, or nil may be passed to indicate that the current
active session should be used. If a session is specified (whether explicitly or by
virtue of being the active session), it must be open and the login method used to
authenticate the user must be native iOS 6.0 authentication. If no session is specified
(and there is no active session), then whether the call succeeds or not will depend on
whether Facebook integration has been configured.
@param viewController The view controller which will present the dialog.
@param session The <FBSession> to use to determine whether or not the user has been
authenticated with iOS native authentication. If nil, then [FBSession activeSession]
will be checked. See discussion above for the implications of nil or non-nil session.
@param initialText The text which will initially be populated in the dialog. The user
will have the opportunity to edit this text before posting it. May be nil.
@param images An array of UIImages that will be attached to the status update. May
be nil.
@param urls An array of NSURLs that will be attached to the status update. May be nil.
@param handler A handler that will be called when the dialog is dismissed, or if an error
occurs. May be nil.
@return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
will still be called, with an error indicating the reason the dialog was not displayed)
*/
+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
session:(FBSession*)session
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBOSIntegratedShareDialogHandler)handler;
/*!
@abstract
Determines whether a call to presentShareDialogModallyFrom: will successfully present
a dialog. This is useful for applications that need to modify the available UI controls
depending on whether the dialog is available on the current platform and for the current
user.
@param session The <FBSession> to use to determine whether or not the user has been
authenticated with iOS native authentication. If nil, then [FBSession activeSession]
will be checked. See discussion above for the implications of nil or non-nil session.
@return YES if the dialog would be presented for the session, and NO if not
*/
+ (BOOL)canPresentOSIntegratedShareDialogWithSession:(FBSession*)session;
/*!
@abstract
Determines whether a call to presentShareDialogWithTarget: will successfully
present a dialog in the Facebook application. This is useful for applications that
need to modify the available UI controls depending on whether the dialog is
available on the current platform.
@param params The parameters for the FB share dialog.
@return YES if the dialog would be presented, and NO if not
@discussion A return value of YES here indicates that the corresponding
presentShareDialogWithParams method will return a non-nil FBAppCall for the same
params. And vice versa.
*/
+ (BOOL)canPresentShareDialogWithParams:(FBShareDialogParams *)params;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share a status
update that may include text, images, or URLs. No session is required, and the app
does not need to be authorized to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param params The parameters for the FB share dialog.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share the
supplied link. No session is required, and the app does not need to be authorized
to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param link The URL link to be attached to the post.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share the
supplied link. No session is required, and the app does not need to be authorized
to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param link The URL link to be attached to the post.
@param name The name, or title associated with the link. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
name:(NSString *)name
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share the
supplied link. No session is required, and the app does not need to be authorized
to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param link The URL link to be attached to the post.
@param name The name, or title associated with the link. May be nil.
@param caption The caption to be used with the link. May be nil.
@param description The description associated with the link. May be nil.
@param picture The link to a thumbnail to associate with the link. May be nil.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
name:(NSString *)name
caption:(NSString *)caption
description:(NSString *)description
picture:(NSURL *)picture
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Determines whether a call to presentShareDialogWithOpenGraphActionParams:clientState:handler:
will successfully present a dialog in the Facebook application. This is useful for applications
that need to modify the available UI controls depending on whether the dialog is
available on the current platform.
@param params The parameters for the FB share dialog.
@return YES if the dialog would be presented, and NO if not
@discussion A return value of YES here indicates that the corresponding
presentShareDialogWithOpenGraphActionParams method will return a non-nil FBAppCall for
the same params. And vice versa.
*/
+ (BOOL)canPresentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionShareDialogParams *)params;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to publish an Open
Graph action. No session is required, and the app does not need to be authorized to call
this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param params The parameters for the Open Graph action dialog.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionShareDialogParams *)params
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to publish the
supplied Open Graph action. No session is required, and the app does not need to be
authorized to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param action The Open Graph action to be published. May not be nil.
@param actionType the fully-specified Open Graph action type of the action (e.g.,
my_app_namespace:my_action).
@param previewPropertyName the name of the property on the action that represents the
primary Open Graph object associated with the action; this object will be displayed in the
preview portion of the share dialog.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
actionType:(NSString *)actionType
previewPropertyName:(NSString *)previewPropertyName
handler:(FBDialogAppCallCompletionHandler) handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to publish the
supplied Open Graph action. No session is required, and the app does not need to be
authorized to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param action The Open Graph action to be published. May not be nil.
@param actionType the fully-specified Open Graph action type of the action (e.g.,
my_app_namespace:my_action).
@param previewPropertyName the name of the property on the action that represents the
primary Open Graph object associated with the action; this object will be displayed in the
preview portion of the share dialog.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
actionType:(NSString *)actionType
previewPropertyName:(NSString *)previewPropertyName
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler) handler;
@end

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2010-present 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>
/*!
@abstract
This class encapsulates state and data related to the presentation and completion
of a dialog.
*/
@interface FBDialogsData : NSObject
/*! @abstract The method being performed */
@property (nonatomic, readonly) NSString *method;
/*! @abstract The arguments being passed to the entity that will show the dialog */
@property (nonatomic, readonly) NSDictionary *arguments;
/*! @abstract Client JSON state that is passed through to the completion handler for context */
@property (nonatomic, readonly) NSDictionary *clientState;
/*! @abstract Results of this FBAppCall that are only set before calling an FBAppCallHandler */
@property (nonatomic, readonly) NSDictionary *results;
@end

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2010-present 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>
/*!
@class FBDialogsParams
@abstract
This object is used as a base class for parameters passed to native dialogs that
open in the Facebook app.
*/
@interface FBDialogsParams : NSObject
@end

View File

@@ -0,0 +1,372 @@
/*
* Copyright 2010-present 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>
/*!
The NSError domain of all errors returned by the Facebook SDK.
*/
extern NSString *const FacebookSDKDomain;
/*!
The NSError domain of all errors surfaced by the Facebook SDK that
were returned by the Facebook Application
*/
extern NSString *const FacebookNativeApplicationDomain;
/*!
The key in the userInfo NSDictionary of NSError where you can find
the inner NSError (if any).
*/
extern NSString *const FBErrorInnerErrorKey;
/*!
The key in the userInfo NSDictionary of NSError for the parsed JSON response
from the server. In case of a batch, includes the JSON for a single FBRequest.
*/
extern NSString *const FBErrorParsedJSONResponseKey;
/*!
The key in the userInfo NSDictionary of NSError indicating
the HTTP status code of the response (if any).
*/
extern NSString *const FBErrorHTTPStatusCodeKey;
/*!
@abstract Error codes returned by the Facebook SDK in NSError.
@discussion
These are valid only in the scope of FacebookSDKDomain.
*/
typedef enum FBErrorCode {
/*!
Like nil for FBErrorCode values, represents an error code that
has not been initialized yet.
*/
FBErrorInvalid = 0,
/// The operation failed because it was cancelled.
FBErrorOperationCancelled,
/// A login attempt failed
FBErrorLoginFailedOrCancelled,
/// The graph API returned an error for this operation.
FBErrorRequestConnectionApi,
/*!
The operation failed because the server returned an unexpected
response. You can get this error if you are not using the most
recent SDK, or if you set your application's migration settings
incorrectly for the version of the SDK you are using.
If this occurs on the current SDK with proper app migration
settings, you may need to try changing to one request per batch.
*/
FBErrorProtocolMismatch,
/// Non-success HTTP status code was returned from the operation.
FBErrorHTTPError,
/// An endpoint that returns a binary response was used with FBRequestConnection;
/// endpoints that return image/jpg, etc. should be accessed using NSURLRequest
FBErrorNonTextMimeTypeReturned,
/// An error occurred while trying to display a native dialog
FBErrorDialog,
/// An error occurred using the FBAppEvents class
FBErrorAppEvents,
/// An error occurred related to an iOS API call
FBErrorSystemAPI,
/// An error occurred while trying to fetch publish install response data
FBErrorPublishInstallResponse,
/*!
The application had its applicationDidBecomeActive: method called while waiting
on a response from the native Facebook app for a pending FBAppCall.
*/
FBErrorAppActivatedWhilePendingAppCall,
/*!
The application had its openURL: method called from a source that was not a
Facebook app and with a URL that was intended for the AppBridge
*/
FBErrorUntrustedURL,
/*!
The URL passed to FBAppCall, was not able to be parsed
*/
FBErrorMalformedURL,
/*!
The operation failed because the session is currently busy reconnecting.
*/
FBErrorSessionReconnectInProgess,
/*!
Reserved for future use.
*/
FBErrorOperationDisallowedForRestrictedTreament,
} FBErrorCode;
/*!
@abstract Error codes returned by the Facebook SDK in NSError.
@discussion
These are valid only in the scope of FacebookNativeApplicationDomain.
*/
typedef enum FBNativeApplicationErrorCode {
// A general error in processing an FBAppCall, without a known cause. Unhandled exceptions are a good example
FBAppCallErrorUnknown = 1,
// The FBAppCall cannot be processed for some reason
FBAppCallErrorUnsupported = 2,
// The FBAppCall is for a method that does not exist (or is turned off)
FBAppCallErrorUnknownMethod = 3,
// The FBAppCall cannot be processed at the moment, but can be retried at a later time.
FBAppCallErrorServiceBusy = 4,
// Share was called in the native Facebook app with incomplete or incorrect arguments
FBShareErrorInvalidParam = 100,
// A server error occurred while calling Share in the native Facebook app.
FBShareErrorServer = 102,
// An unknown error occurred while calling Share in the native Facebook app.
FBShareErrorUnknown = 103,
// Disallowed from calling Share in the native Facebook app.
FBShareErrorDenied = 104,
} FBNativeApplicationErrorCode;
/*!
@typedef FBErrorCategory enum
@abstract Indicates the Facebook SDK classification for the error
@discussion
*/
typedef enum {
/*! Indicates that the error category is invalid and likely represents an error that
is unrelated to Facebook or the Facebook SDK */
FBErrorCategoryInvalid = 0,
/*! Indicates that the error may be authentication related but the application should retry the operation.
This case may involve user action that must be taken, and so the application should also test
the fberrorShouldNotifyUser property and if YES display fberrorUserMessage to the user before retrying.*/
FBErrorCategoryRetry = 1,
/*! Indicates that the error is authentication related and the application should reopen the session*/
FBErrorCategoryAuthenticationReopenSession = 2,
/*! Indicates that the error is permission related */
FBErrorCategoryPermissions = 3,
/*! Indicates that the error implies that the server had an unexpected failure or may be temporarily down */
FBErrorCategoryServer = 4,
/*! Indicates that the error results from the server throttling the client */
FBErrorCategoryThrottling = 5,
/*! Indicates the user cancelled the operation */
FBErrorCategoryUserCancelled = 6,
/*! Indicates that the error is Facebook-related but is uncategorizable, and likely newer than the
current version of the SDK */
FBErrorCategoryFacebookOther = -1,
/*! Indicates that the error is an application error resulting in a bad or malformed request to the server. */
FBErrorCategoryBadRequest = -2,
} FBErrorCategory;
/*!
The key in the userInfo NSDictionary of NSError where you can find
the inner NSError (if any).
*/
extern NSString *const FBErrorInnerErrorKey;
/*!
The key in the userInfo NSDictionary of NSError where you can find
the session associated with the error (if any).
*/
extern NSString *const FBErrorSessionKey;
/*!
The key in the userInfo NSDictionary of NSError that points to the URL
that caused an error, in its processing by FBAppCall.
*/
extern NSString *const FBErrorUnprocessedURLKey;
/*!
The key in the userInfo NSDictionary of NSError for unsuccessful
logins (error.code equals FBErrorLoginFailedOrCancelled). If present,
the value will be one of the constants prefixed by FBErrorLoginFailedReason*.
*/
extern NSString *const FBErrorLoginFailedReason;
/*!
The key in the userInfo NSDictionary of NSError for unsuccessful
logins (error.code equals FBErrorLoginFailedOrCancelled). If present,
the value indicates an original login error code wrapped by this error.
This is only used in the web dialog login flow.
*/
extern NSString *const FBErrorLoginFailedOriginalErrorCode;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
cancelled a web dialog auth.
*/
extern NSString *const FBErrorLoginFailedReasonInlineCancelledValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
did not cancel a web dialog auth.
*/
extern NSString *const FBErrorLoginFailedReasonInlineNotCancelledValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
cancelled a non-iOS 6 SSO (either Safari or Facebook App) login.
*/
extern NSString *const FBErrorLoginFailedReasonUserCancelledValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
cancelled an iOS system login.
*/
extern NSString *const FBErrorLoginFailedReasonUserCancelledSystemValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates an error
condition. You may inspect the rest of userInfo for other data.
*/
extern NSString *const FBErrorLoginFailedReasonOtherError;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the app's
slider in iOS 6 (device Settings -> Privacy -> Facebook {app} ) has
been disabled.
*/
extern NSString *const FBErrorLoginFailedReasonSystemDisallowedWithoutErrorValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates an error
has occurred when requesting Facebook account acccess in iOS 6 that was
not `FBErrorLoginFailedReasonSystemDisallowedWithoutErrorValue` nor
a user cancellation.
*/
extern NSString *const FBErrorLoginFailedReasonSystemError;
extern NSString *const FBErrorLoginFailedReasonUnitTestResponseUnrecognized;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails. Indicates
the request for new permissions has failed because the session was closed.
*/
extern NSString *const FBErrorReauthorizeFailedReasonSessionClosed;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails. Indicates
the request for new permissions has failed because the user cancelled.
*/
extern NSString *const FBErrorReauthorizeFailedReasonUserCancelled;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails on
iOS 6 with the Facebook account. Indicates the request for new permissions has
failed because the user cancelled.
*/
extern NSString *const FBErrorReauthorizeFailedReasonUserCancelledSystem;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails. Indicates
the request for new permissions has failed because the request was
for a different user than the original permission set.
*/
extern NSString *const FBErrorReauthorizeFailedReasonWrongUser;
/*!
The key in the userInfo NSDictionary of NSError for errors
encountered with `FBDialogs` operations. (error.code equals FBErrorDialog).
If present, the value will be one of the constants prefixed by FBErrorDialog*.
*/
extern NSString *const FBErrorDialogReasonKey;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog is not supported
in the current OS.
*/
extern NSString *const FBErrorDialogNotSupported;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed because it is not appropriate for the current session.
*/
extern NSString *const FBErrorDialogInvalidForSession;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed for some other reason.
*/
extern NSString *const FBErrorDialogCantBeDisplayed;
/*!
A value that may appear in the NSError userInfo ditionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed because an Open Graph object that was passed was not configured
correctly. The object must either (a) exist by having an 'id' or 'url' value;
or, (b) configured for creation (by setting the 'type' value and
provisionedForPost property)
*/
extern NSString *const FBErrorDialogInvalidOpenGraphObject;
/*!
A value that may appear in the NSError userInfo ditionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed because the parameters for sharing an Open Graph action were
not configured. The parameters must include an 'action', 'actionType', and
'previewPropertyName'.
*/
extern NSString *const FBErrorDialogInvalidOpenGraphActionParameters;
/*!
The key in the userInfo NSDictionary of NSError for errors
encountered with `FBAppEvents` operations (error.code equals FBErrorAppEvents).
*/
extern NSString *const FBErrorAppEventsReasonKey;
// Exception strings raised by the Facebook SDK
/*!
This exception is raised by methods in the Facebook SDK to indicate
that an attempted operation is invalid
*/
extern NSString *const FBInvalidOperationException;
// Facebook SDK also raises exceptions the following common exceptions:
// NSInvalidArgumentException

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2010-present 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.
*/
/*!
@class FBErrorUtility
@abstract A utility class with methods to provide more information for Facebook
related errors if you do not want to use the NSError(FBError) category.
*/
@interface FBErrorUtility : NSObject
/*!
@abstract
Categorizes the error, if it is Facebook related, to simplify application mitigation behavior
@discussion
In general, in response to an error connecting to Facebook, an application should, retry the
operation, request permissions, reconnect the application, or prompt the user to take an action.
The error category can be used to understand the class of error received from Facebook. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
@param error the error to be categorized.
*/
+(FBErrorCategory) errorCategoryForError:(NSError *)error;
/*!
@abstract
If YES indicates that a user action is required in order to successfully continue with the facebook operation
@discussion
In general if this returns NO, then the application has a straightforward mitigation, such as
retry the operation or request permissions from the user, etc. In some cases it is necessary for the user to
take an action before the application continues to attempt a Facebook connection. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
@param error the error to inspect.
*/
+(BOOL) shouldNotifyUserForError:(NSError *)error;
/*!
@abstract
A message suitable for display to the user, describing a user action necessary to enable Facebook functionality.
Not all Facebook errors yield a message suitable for user display; however in all cases where
fberrorShouldNotifyUser is YES, this property returns a localizable message suitable for display.
@param error the error to inspect.
*/
+(NSString *) userMessageForError:(NSError *)error;
@end

View File

@@ -0,0 +1,87 @@
/*
* Copyright 2010-present 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 "FBCacheDescriptor.h"
#import "FBRequest.h"
#import "FBWebDialogs.h"
/*!
@class FBFrictionlessRecipientCache
@abstract
Maintains a cache of friends that can recieve application requests from the user in
using the frictionless feature of the requests web dialog.
This class follows the `FBCacheDescriptor` pattern used elsewhere in the SDK, and applications may call
one of the prefetchAndCacheForSession methods to fetch a friend list prior to the
point where a dialog is presented. The cache is also updated with each presentation of the request
dialog using the cache instance.
*/
@interface FBFrictionlessRecipientCache : FBCacheDescriptor<FBWebDialogsDelegate>
/*!
@abstract
Initializes an empty cache instance
*/
- (id)init;
/*! @abstract An array containing the list of known FBIDs for recipients enabled for frictionless requests */
@property (nonatomic, readwrite, copy) NSArray *recipientIDs;
/*!
@abstract
Checks to see if a given user or FBID for a user is known to be enabled for
frictionless requestests
@param user An NSString, NSNumber of `FBGraphUser` representing a user to check
*/
- (BOOL)isFrictionlessRecipient:(id)user;
/*!
@abstract
Checks to see if a collection of users or FBIDs for users are known to be enabled for
frictionless requestests
@param users An NSArray of NSString, NSNumber of `FBGraphUser` objects
representing users to check
*/
- (BOOL)areFrictionlessRecipients:(NSArray*)users;
/*!
@abstract
Issues a request and fills the cache with a list of users to use for frictionless requests
@param session The session to use for the request; nil indicates that the Active Session should
be used
*/
- (void)prefetchAndCacheForSession:(FBSession *)session;
/*!
@abstract
Issues a request and fills the cache with a list of users to use for frictionless requests
@param session The session to use for the request; nil indicates that the Active Session should
be used
@param handler An optional completion handler, called when the request for cached users has
completed. It can be useful to use the handler to enable UI or perform other request-related
operations, after the cache is populated.
*/
- (void)prefetchAndCacheForSession:(FBSession *)session
completionHandler:(FBRequestHandler)handler;
@end

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2010-present 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>
@class FBRequest;
@class Facebook;
/**
* Do not use this interface directly, instead, use methods in Facebook.h
*
* Handles frictionless interaction and recipient-caching by the SDK,
* see https://developers.facebook.com/docs/reference/dialogs/requests/
*/
@interface FBFrictionlessRequestSettings : NSObject {
@private
NSArray* _allowedRecipients;
FBRequest* _activeRequest;
BOOL _enabled;
}
/**
* BOOL indicating whether frictionless request sending has been enabled
*/
@property (nonatomic, readonly) BOOL enabled;
/**
* NSArray of recipients
*/
@property (nonatomic, readonly) NSArray *recipientIDs;
/**
* Enable frictionless request sending by the sdk; this means:
* 1. query and cache the current set of frictionless recipients
* 2. flag other facets of the sdk to behave in a frictionless way
*/
- (void)enableWithFacebook:(Facebook*)facebook;
/**
* Reload recipient cache; called by the sdk to keep the cache fresh;
* method makes graph request: me/apprequestformerrecipients
*/
- (void)reloadRecipientCacheWithFacebook:(Facebook*)facebook;
/**
* Update the recipient cache; called by the sdk to keep the cache fresh;
*/
- (void)updateRecipientCacheWithRecipients:(NSArray*)ids;
/**
* Update the recipient cache, using a request result
*/
- (void)updateRecipientCacheWithRequestResult:(id)result;
/**
* Given an fbID for a user, indicates whether user is enabled for
* frictionless calls
*/
- (BOOL)isFrictionlessEnabledForRecipient:(id)fbid;
/**
* Given an array of user fbIDs, indicates whether they are enabled for
* frictionless calls
*/
- (BOOL)isFrictionlessEnabledForRecipients:(NSArray*)fbids;
/**
* init the frictionless cache object
*/
- (id)init;
@end

View File

@@ -0,0 +1,296 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
#import "FBCacheDescriptor.h"
#import "FBGraphUser.h"
#import "FBSession.h"
#import "FBViewController.h"
@protocol FBFriendPickerDelegate;
@class FBFriendPickerCacheDescriptor;
/*!
@typedef FBFriendSortOrdering enum
@abstract Indicates the order in which friends should be listed in the friend picker.
@discussion
*/
typedef enum {
/*! Sort friends by first, middle, last names. */
FBFriendSortByFirstName,
/*! Sort friends by last, first, middle names. */
FBFriendSortByLastName
} FBFriendSortOrdering;
/*!
@typedef FBFriendDisplayOrdering enum
@abstract Indicates whether friends should be displayed first-name-first or last-name-first.
@discussion
*/
typedef enum {
/*! Display friends as First Middle Last. */
FBFriendDisplayByFirstName,
/*! Display friends as Last First Middle. */
FBFriendDisplayByLastName,
} FBFriendDisplayOrdering;
/*!
@class
@abstract
The `FBFriendPickerViewController` class creates a controller object that manages
the user interface for displaying and selecting Facebook friends.
@discussion
When the `FBFriendPickerViewController` view loads it creates a `UITableView` object
where the friends will be displayed. You can access this view through the `tableView`
property. The friend display can be sorted by first name or last name. Friends'
names can be displayed with the first name first or the last name first.
The friend data can be pre-fetched and cached prior to using the view controller. The
cache is setup using an <FBCacheDescriptor> object that can trigger the
data fetch. Any friend data requests will first check the cache and use that data.
If the friend picker is being displayed cached data will initially be shown before
a fresh copy is retrieved.
The `delegate` property may be set to an object that conforms to the <FBFriendPickerDelegate>
protocol. The `delegate` object will receive updates related to friend selection and
data changes. The delegate can also be used to filter the friends to display in the
picker.
*/
@interface FBFriendPickerViewController : FBViewController
/*!
@abstract
Returns an outlet for the spinner used in the view controller.
*/
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner;
/*!
@abstract
Returns an outlet for the table view managed by the view controller.
*/
@property (nonatomic, retain) IBOutlet UITableView *tableView;
/*!
@abstract
A Boolean value that specifies whether multi-select is enabled.
*/
@property (nonatomic) BOOL allowsMultipleSelection;
/*!
@abstract
A Boolean value that indicates whether friend profile pictures are displayed.
*/
@property (nonatomic) BOOL itemPicturesEnabled;
/*!
@abstract
Addtional fields to fetch when making the Graph API call to get friend data.
*/
@property (nonatomic, copy) NSSet *fieldsForRequest;
/*!
@abstract
The session that is used in the request for friend data.
*/
@property (nonatomic, retain) FBSession *session;
/*!
@abstract
The profile ID of the user whose friends are being viewed.
*/
@property (nonatomic, copy) NSString *userID;
/*!
@abstract
The list of friends that are currently selected in the veiw.
The items in the array are <FBGraphUser> objects.
@discussion
You can set this this array to pre-select items in the picker. The objects in the array
must be complete id<FBGraphUser> objects (i.e., fetched from a Graph query or from a
previous picker's selection, with id and appropriate name fields).
*/
@property (nonatomic, copy) NSArray *selection;
/*!
@abstract
The order in which friends are sorted in the display.
*/
@property (nonatomic) FBFriendSortOrdering sortOrdering;
/*!
@abstract
The order in which friends' names are displayed.
*/
@property (nonatomic) FBFriendDisplayOrdering displayOrdering;
/*!
@abstract
Initializes a friend picker view controller.
*/
- (id)init;
/*!
@abstract
Initializes a friend picker view controller.
@param aDecoder An unarchiver object.
*/
- (id)initWithCoder:(NSCoder *)aDecoder;
/*!
@abstract
Used to initialize the object
@param nibNameOrNil The name of the nib file to associate with the view controller. The nib file name should not contain any leading path information. If you specify nil, the nibName property is set to nil.
@param nibBundleOrNil The bundle in which to search for the nib file. This method looks for the nib file in the bundle's language-specific project directories first, followed by the Resources directory. If nil, this method looks for the nib file in the main bundle.
*/
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
/*!
@abstract
Configures the properties used in the caching data queries.
@discussion
Cache descriptors are used to fetch and cache the data used by the view controller.
If the view controller finds a cached copy of the data, it will
first display the cached content then fetch a fresh copy from the server.
@param cacheDescriptor The <FBCacheDescriptor> containing the cache query properties.
*/
- (void)configureUsingCachedDescriptor:(FBCacheDescriptor*)cacheDescriptor;
/*!
@abstract
Initiates a query to get friend data.
@discussion
A cached copy will be returned if available. The cached view is temporary until a fresh copy is
retrieved from the server. It is legal to call this more than once.
*/
- (void)loadData;
/*!
@abstract
Updates the view locally without fetching data from the server or from cache.
@discussion
Use this if the filter or sort properties change. This may affect the order or
display of friend information but should not need require new data.
*/
- (void)updateView;
/*!
@abstract
Clears the current selection, so the picker is ready for a fresh use.
*/
- (void)clearSelection;
/*!
@method
@abstract
Creates a cache descriptor based on default settings of the `FBFriendPickerViewController` object.
@discussion
An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
the view controller. It may also be used to configure the `FBFriendPickerViewController`
object.
*/
+ (FBCacheDescriptor*)cacheDescriptor;
/*!
@method
@abstract
Creates a cache descriptor with additional fields and a profile ID for use with the `FBFriendPickerViewController` object.
@discussion
An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
the view controller. It may also be used to configure the `FBFriendPickerViewController`
object.
@param userID The profile ID of the user whose friends will be displayed. A nil value implies a "me" alias.
@param fieldsForRequest The set of additional fields to include in the request for friend data.
*/
+ (FBCacheDescriptor*)cacheDescriptorWithUserID:(NSString*)userID fieldsForRequest:(NSSet*)fieldsForRequest;
@end
/*!
@protocol
@abstract
The `FBFriendPickerDelegate` protocol defines the methods used to receive event
notifications and allow for deeper control of the <FBFriendPickerViewController>
view.
*/
@protocol FBFriendPickerDelegate <FBViewControllerDelegate>
@optional
/*!
@abstract
Tells the delegate that data has been loaded.
@discussion
The <FBFriendPickerViewController> object's `tableView` property is automatically
reloaded when this happens. However, if another table view, for example the
`UISearchBar` is showing data, then it may also need to be reloaded.
@param friendPicker The friend picker view controller whose data changed.
*/
- (void)friendPickerViewControllerDataDidChange:(FBFriendPickerViewController *)friendPicker;
/*!
@abstract
Tells the delegate that the selection has changed.
@param friendPicker The friend picker view controller whose selection changed.
*/
- (void)friendPickerViewControllerSelectionDidChange:(FBFriendPickerViewController *)friendPicker;
/*!
@abstract
Asks the delegate whether to include a friend in the list.
@discussion
This can be used to implement a search bar that filters the friend list.
@param friendPicker The friend picker view controller that is requesting this information.
@param user An <FBGraphUser> object representing the friend.
*/
- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
shouldIncludeUser:(id <FBGraphUser>)user;
/*!
@abstract
Tells the delegate that there is a communication error.
@param friendPicker The friend picker view controller that encountered the error.
@param error An error object containing details of the error.
*/
- (void)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
handleError:(NSError *)error;
@end

View File

@@ -0,0 +1,78 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
/*!
@protocol
@abstract
The `FBGraphLocation` protocol enables typed access to the `location` property
of a Facebook place object.
@discussion
The `FBGraphLocation` protocol represents the most commonly used properties of a
location object. It may be used to access an `NSDictionary` object that has
been wrapped with an <FBGraphObject> facade.
*/
@protocol FBGraphLocation<FBGraphObject>
/*!
@property
@abstract Typed access to a location's street.
*/
@property (retain, nonatomic) NSString *street;
/*!
@property
@abstract Typed access to a location's city.
*/
@property (retain, nonatomic) NSString *city;
/*!
@property
@abstract Typed access to a location's state.
*/
@property (retain, nonatomic) NSString *state;
/*!
@property
@abstract Typed access to a location's country.
*/
@property (retain, nonatomic) NSString *country;
/*!
@property
@abstract Typed access to a location's zip code.
*/
@property (retain, nonatomic) NSString *zip;
/*!
@property
@abstract Typed access to a location's latitude.
*/
@property (retain, nonatomic) NSNumber *latitude;
/*!
@property
@abstract Typed access to a location's longitude.
*/
@property (retain, nonatomic) NSNumber *longitude;
@end

View File

@@ -0,0 +1,269 @@
/*
* Copyright 2010-present 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>
@protocol FBOpenGraphObject;
@protocol FBOpenGraphAction;
/*!
@protocol
@abstract
The `FBGraphObject` protocol is the base protocol which enables typed access to graph objects and
open graph objects. Inherit from this protocol or a sub-protocol in order to introduce custom types
for typed access to Facebook objects.
@discussion
The `FBGraphObject` protocol is the core type used by the Facebook SDK for iOS to
represent objects in the Facebook Social Graph and the Facebook Open Graph (OG).
The `FBGraphObject` class implements useful default functionality, but is rarely
used directly by applications. The `FBGraphObject` protocol, in contrast is the
base protocol for all graph object access via the SDK.
Goals of the FBGraphObject types:
<ul>
<li> Lightweight/maintainable/robust </li>
<li> Extensible and resilient to change, both by Facebook and third party (OG) </li>
<li> Simple and natural extension to Objective-C </li>
</ul>
The FBGraphObject at its core is a duck typed (if it walks/swims/quacks...
its a duck) model which supports an optional static facade. Duck-typing achieves
the flexibility necessary for Social Graph and OG uses, and the static facade
increases discoverability, maintainability, robustness and simplicity.
The following excerpt from the PlacePickerSample shows a simple use of the
a facade protocol `FBGraphPlace` by an application:
<pre>
&dash; (void)placePickerViewControllerSelectionDidChange:(FBPlacePickerViewController *)placePicker
{
id&#060;FBGraphPlace&#062; place = placePicker.selection;
// we'll use logging to show the simple typed property access to place and location info
NSLog(@"place=%@, city=%@, state=%@, lat long=%@ %@",
place.name,
place.location.city,
place.location.state,
place.location.latitude,
place.location.longitude);
}
</pre>
Note that in this example, access to common place information is available through typed property
syntax. But if at some point places in the Social Graph supported additional fields "foo" and "bar", not
reflected in the `FBGraphPlace` protocol, the application could still access the values like so:
<pre>
NSString *foo = [place objectForKey:@"foo"]; // perhaps located at the ... in the preceding example
NSNumber *bar = [place objectForKey:@"bar"]; // extensibility applies to Social and Open graph uses
</pre>
In addition to untyped access, applications and future revisions of the SDK may add facade protocols by
declaring a protocol inheriting the `FBGraphObject` protocol, like so:
<pre>
&#064;protocol MyGraphThing&#060;FBGraphObject&#062;
&#064;property (copy, nonatomic) NSString *id;
&#064;property (copy, nonatomic) NSString *name;
&#064;end
</pre>
Important: facade implementations are inferred by graph objects returned by the methods of the SDK. This
means that no explicit implementation is required by application or SDK code. Any `FBGraphObject` instance
may be cast to any `FBGraphObject` facade protocol, and accessed via properties. If a field is not present
for a given facade property, the property will return nil.
The following layer diagram depicts some of the concepts discussed thus far:
<pre>
*-------------* *------------* *-------------**--------------------------*
Facade --> | FBGraphUser | |FBGraphPlace| | MyGraphThing|| MyGraphPersonExtentension| ...
*-------------* *------------* *-------------**--------------------------*
*------------------------------------* *--------------------------------------*
Transparent impl --> | FBGraphObject (instances) | | CustomClass&#060;FBGraphObject&#062; |
*------------------------------------* *--------------------------------------*
*-------------------**------------------------* *-----------------------------*
Apparent impl --> |NSMutableDictionary||FBGraphObject (protocol)| |FBGraphObject (class methods)|
*-------------------**------------------------* *-----------------------------*
</pre>
The *Facade* layer is meant for typed access to graph objects. The *Transparent impl* layer (more
specifically, the instance capabilities of `FBGraphObject`) are used by the SDK and app logic
internally, but are not part of the public interface between application and SDK. The *Apparent impl*
layer represents the lower-level "duck-typed" use of graph objects.
Implementation note: the SDK returns `NSMutableDictionary` derived instances with types declared like
one of the following:
<pre>
NSMutableDictionary&#060;FBGraphObject&#062; *obj; // no facade specified (still castable by app)
NSMutableDictionary&#060;FBGraphPlace&#062; *person; // facade specified when possible
</pre>
However, when passing a graph object to the SDK, `NSMutableDictionary` is not assumed; only the
FBGraphObject protocol is assumed, like so:
<pre>
id&#060;FBGraphObject&#062; anyGraphObj;
</pre>
As such, the methods declared on the `FBGraphObject` protocol represent the methods used by the SDK to
consume graph objects. While the `FBGraphObject` class implements the full `NSMutableDictionary` and KVC
interfaces, these are not consumed directly by the SDK, and are optional for custom implementations.
*/
@protocol FBGraphObject<NSObject>
/*!
@method
@abstract
Returns the number of properties on this `FBGraphObject`.
*/
- (NSUInteger)count;
/*!
@method
@abstract
Returns a property on this `FBGraphObject`.
@param aKey name of the property to return
*/
- (id)objectForKey:(id)aKey;
/*!
@method
@abstract
Returns an enumerator of the property naems on this `FBGraphObject`.
*/
- (NSEnumerator *)keyEnumerator;
/*!
@method
@abstract
Removes a property on this `FBGraphObject`.
@param aKey name of the property to remove
*/
- (void)removeObjectForKey:(id)aKey;
/*!
@method
@abstract
Sets the value of a property on this `FBGraphObject`.
@param anObject the new value of the property
@param aKey name of the property to set
*/
- (void)setObject:(id)anObject forKey:(id)aKey;
@optional
/*!
@abstract
This property signifies that the current graph object is provisioned for POST (as a definition
for a new or updated graph object), and should be posted AS-IS in its JSON encoded form, whereas
some graph objects (usually those embedded in other graph objects as references to existing objects)
may only have their "id" or "url" posted.
*/
@property (nonatomic, assign) BOOL provisionedForPost;
@end
/*!
@class
@abstract
Static class with helpers for use with graph objects
@discussion
The public interface of this class is useful for creating objects that have the same graph characteristics
of those returned by methods of the SDK. This class also represents the internal implementation of the
`FBGraphObject` protocol, used by the Facebook SDK. Application code should not use the `FBGraphObject` class to
access instances and instance members, favoring the protocol.
*/
@interface FBGraphObject : NSMutableDictionary<FBGraphObject>
/*!
@method
@abstract
Used to create a graph object, usually for use in posting a new graph object or action.
*/
+ (NSMutableDictionary<FBGraphObject>*)graphObject;
/*!
@method
@abstract
Used to wrap an existing dictionary with a `FBGraphObject` facade
@discussion
Normally you will not need to call this method, as the Facebook SDK already "FBGraphObject-ifys" json objects
fetch via `FBRequest` and `FBRequestConnection`. However, you may have other reasons to create json objects in your
application, which you would like to treat as a graph object. The pattern for doing this is that you pass the root
node of the json to this method, to retrieve a wrapper. From this point, if you traverse the graph, any other objects
deeper in the hierarchy will be wrapped as `FBGraphObject`'s in a lazy fashion.
This method is designed to avoid unnecessary memory allocations, and object copying. Due to this, the method does
not copy the source object if it can be avoided, but rather wraps and uses it as is. The returned object derives
callers shoudl use the returned object after calls to this method, rather than continue to call methods on the original
object.
@param jsonDictionary the dictionary representing the underlying object to wrap
*/
+ (NSMutableDictionary<FBGraphObject>*)graphObjectWrappingDictionary:(NSDictionary*)jsonDictionary;
/*!
@method
@abstract
Used to create a graph object that's provisioned for POST, usually for use in posting a new Open Graph Action.
*/
+ (NSMutableDictionary<FBOpenGraphAction>*)openGraphActionForPost;
/*!
@method
@abstract
Used to create a graph object that's provisioned for POST, usually for use in posting a new Open Graph object.
*/
+ (NSMutableDictionary<FBOpenGraphObject>*)openGraphObjectForPost;
/*!
@method
@abstract
Used to create a graph object that's provisioned for POST, usually for use in posting a new Open Graph object.
@param type the object type name, in the form namespace:typename
@param title a title for the object
@param image the image property for the object
@param url the url property for the object
@param description the description for the object
*/
+ (NSMutableDictionary<FBOpenGraphObject>*)openGraphObjectForPostWithType:(NSString *)type
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description;
/*!
@method
@abstract
Used to compare two `FBGraphObject`s to determine if represent the same object. We do not overload
the concept of equality as there are various types of equality that may be important for an `FBGraphObject`
(for instance, two different `FBGraphObject`s could represent the same object, but contain different
subsets of fields).
@param anObject an `FBGraphObject` to test
@param anotherObject the `FBGraphObject` to compare it against
*/
+ (BOOL)isGraphObjectID:(id<FBGraphObject>)anObject sameAs:(id<FBGraphObject>)anotherObject;
@end

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2010-present 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 "FBGraphLocation.h"
#import "FBGraphObject.h"
/*!
@protocol
@abstract
The `FBGraphPlace` protocol enables typed access to a place object
as represented in the Graph API.
@discussion
The `FBGraphPlace` protocol represents the most commonly used properties of a
Facebook place object. It may be used to access an `NSDictionary` object that has
been wrapped with an <FBGraphObject> facade.
*/
@protocol FBGraphPlace<FBGraphObject>
/*!
@property
@abstract Typed access to the place ID.
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to the place name.
*/
@property (retain, nonatomic) NSString *name;
/*!
@property
@abstract Typed access to the place category.
*/
@property (retain, nonatomic) NSString *category;
/*!
@property
@abstract Typed access to the place location.
*/
@property (retain, nonatomic) id<FBGraphLocation> location;
@end

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
#import "FBGraphPlace.h"
/*!
@protocol
@abstract
The `FBGraphUser` protocol enables typed access to a user object
as represented in the Graph API.
@discussion
The `FBGraphUser` protocol represents the most commonly used properties of a
Facebook user object. It may be used to access an `NSDictionary` object that has
been wrapped with an <FBGraphObject> facade.
*/
@protocol FBGraphUser<FBGraphObject>
/*!
@property
@abstract Typed access to the user's ID.
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to the user's name.
*/
@property (retain, nonatomic) NSString *name;
/*!
@property
@abstract Typed access to the user's first name.
*/
@property (retain, nonatomic) NSString *first_name;
/*!
@property
@abstract Typed access to the user's middle name.
*/
@property (retain, nonatomic) NSString *middle_name;
/*!
@property
@abstract Typed access to the user's last name.
*/
@property (retain, nonatomic) NSString *last_name;
/*!
@property
@abstract Typed access to the user's profile URL.
*/
@property (retain, nonatomic) NSString *link;
/*!
@property
@abstract Typed access to the user's username.
*/
@property (retain, nonatomic) NSString *username;
/*!
@property
@abstract Typed access to the user's birthday.
*/
@property (retain, nonatomic) NSString *birthday;
/*!
@property
@abstract Typed access to the user's current city.
*/
@property (retain, nonatomic) id<FBGraphPlace> location;
@end

View File

@@ -0,0 +1,57 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@typedef FBInsightsFlushBehavior enum
@abstract This enum has been deprecated in favor of FBAppEventsFlushBehavior.
*/
__attribute__ ((deprecated("use FBAppEventsFlushBehavior instead")))
typedef enum {
FBInsightsFlushBehaviorAuto __attribute__ ((deprecated("use FBAppEventsFlushBehaviorAuto instead"))),
FBInsightsFlushBehaviorExplicitOnly __attribute__ ((deprecated("use FBAppEventsFlushBehaviorExplicitOnly instead"))),
} FBInsightsFlushBehavior;
extern NSString *const FBInsightsLoggingResultNotification __attribute__((deprecated));
/*!
@class FBInsights
@abstract This class has been deprecated in favor of FBAppEvents.
*/
__attribute__ ((deprecated("Use the FBAppEvents class instead")))
@interface FBInsights : NSObject
+ (NSString *)appVersion __attribute__((deprecated));
+ (void)setAppVersion:(NSString *)appVersion __attribute__((deprecated("use [FBSettings setAppVersion] instead")));
+ (void)logPurchase:(double)purchaseAmount currency:(NSString *)currency __attribute__((deprecated("use [FBAppEvents logPurchase] instead")));
+ (void)logPurchase:(double)purchaseAmount currency:(NSString *)currency parameters:(NSDictionary *)parameters __attribute__((deprecated("use [FBAppEvents logPurchase] instead")));
+ (void)logPurchase:(double)purchaseAmount currency:(NSString *)currency parameters:(NSDictionary *)parameters session:(FBSession *)session __attribute__((deprecated("use [FBAppEvents logPurchase] instead")));
+ (void)logConversionPixel:(NSString *)pixelID valueOfPixel:(double)value __attribute__((deprecated));
+ (void)logConversionPixel:(NSString *)pixelID valueOfPixel:(double)value session:(FBSession *)session __attribute__((deprecated));
+ (FBInsightsFlushBehavior)flushBehavior __attribute__((deprecated("use [FBAppEvents flushBehavior] instead")));
+ (void)setFlushBehavior:(FBInsightsFlushBehavior)flushBehavior __attribute__((deprecated("use [FBAppEvents setFlushBehavior] instead")));
+ (void)flush __attribute__((deprecated("use [FBAppEvents flush] instead")));
@end

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2010-present 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 params:(NSDictionary *)params;
- (void)fbDialogNotLogin:(BOOL)cancelled;
@end

View File

@@ -0,0 +1,189 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
#import "FBGraphUser.h"
#import "FBSession.h"
@protocol FBLoginViewDelegate;
/*!
@class FBLoginView
@abstract FBLoginView is a custom UIView that renders a button to login or logout based on the
state of `FBSession.activeSession`
@discussion This view is closely associated with `FBSession.activeSession`. Upon initialization,
it will attempt to open an active session without UI if the current active session is not open.
The FBLoginView instance also monitors for changes to the active session.
*/
@interface FBLoginView : UIView
/*!
@abstract
The permissions to login with. Defaults to nil, meaning basic permissions.
@discussion Methods and properties that specify permissions without a read or publish
qualification are deprecated; use of a read-qualified or publish-qualified alternative is preferred.
*/
@property (readwrite, copy) NSArray *permissions __attribute__((deprecated));
/*!
@abstract
The read permissions to request if the user logs in via this view. The basic_info permission must be explicitly requested at
first login, and is no longer inferred, (subject to an active migration.)
@discussion
Note, that if read permissions are specified, then publish permissions should not be specified.
*/
@property (nonatomic, copy) NSArray *readPermissions;
/*!
@abstract
The publish permissions to request if the user logs in via this view.
@discussion
Note, that a defaultAudience value of FBSessionDefaultAudienceOnlyMe, FBSessionDefaultAudienceEveryone, or
FBSessionDefaultAudienceFriends should be set if publish permissions are specified. Additionally, when publish
permissions are specified, then read should not be specified.
*/
@property (nonatomic, copy) NSArray *publishPermissions;
/*!
@abstract
The default audience to use, if publish permissions are requested at login time.
*/
@property (nonatomic, assign) FBSessionDefaultAudience defaultAudience;
/*!
@abstract
The login behavior for the active session if the user logs in via this view
@discussion
The default value is FBSessionLoginBehaviorUseSystemAccountIfPresent.
*/
@property (nonatomic) FBSessionLoginBehavior loginBehavior;
/*!
@abstract
Initializes and returns an `FBLoginView` object. The underlying session has basic permissions granted to it.
*/
- (id)init;
/*!
@method
@abstract
Initializes and returns an `FBLoginView` object constructed with the specified permissions.
@param permissions An array of strings representing the permissions to request during the
authentication flow. A value of nil will indicates basic permissions.
@discussion Methods and properties that specify permissions without a read or publish
qualification are deprecated; use of a read-qualified or publish-qualified alternative is preferred.
*/
- (id)initWithPermissions:(NSArray *)permissions __attribute__((deprecated));
/*!
@method
@abstract
Initializes and returns an `FBLoginView` object constructed with the specified permissions.
@param readPermissions An array of strings representing the read permissions to request during the
authentication flow. A value of nil will indicates basic permissions.
*/
- (id)initWithReadPermissions:(NSArray *)readPermissions;
/*!
@method
@abstract
Initializes and returns an `FBLoginView` object constructed with the specified permissions.
@param publishPermissions An array of strings representing the publish permissions to request during the
authentication flow.
@param defaultAudience An audience for published posts; note that FBSessionDefaultAudienceNone is not valid
for permission requests that include publish or manage permissions.
*/
- (id)initWithPublishPermissions:(NSArray *)publishPermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience;
/*!
@abstract
The delegate object that receives updates for selection and display control.
*/
@property (nonatomic, assign) IBOutlet id<FBLoginViewDelegate> delegate;
@end
/*!
@protocol
@abstract
The `FBLoginViewDelegate` protocol defines the methods used to receive event
notifications from `FBLoginView` objects.
*/
@protocol FBLoginViewDelegate <NSObject>
@optional
/*!
@abstract
Tells the delegate that the view is now in logged in mode
@param loginView The login view that transitioned its view mode
*/
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView;
/*!
@abstract
Tells the delegate that the view is has now fetched user info
@param loginView The login view that transitioned its view mode
@param user The user info object describing the logged in user
*/
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user;
/*!
@abstract
Tells the delegate that the view is now in logged out mode
@param loginView The login view that transitioned its view mode
*/
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView;
/*!
@abstract
Tells the delegate that there is a communication or authorization error.
@param loginView The login view that transitioned its view mode
@param error An error object containing details of the error.
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
*/
- (void)loginView:(FBLoginView *)loginView
handleError:(NSError *)error;
@end

View File

@@ -0,0 +1,109 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "FBAppCall.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBShareDialogParams.h"
@class FBSession;
@protocol FBOpenGraphAction;
// note that the following class and types are deprecated in favor of FBDialogs and its methods
/*!
@typedef FBNativeDialogResult enum
@abstract
Please note that this enum and its related methods have been deprecated, please migrate your
code to use `FBOSIntegratedShareDialogResult` and its related methods.
*/
typedef enum {
/*! Indicates that the dialog action completed successfully. */
FBNativeDialogResultSucceeded,
/*! Indicates that the dialog action was cancelled (either by the user or the system). */
FBNativeDialogResultCancelled,
/*! Indicates that the dialog could not be shown (because not on ios6 or ios6 auth was not used). */
FBNativeDialogResultError
} FBNativeDialogResult
__attribute__((deprecated));
/*!
@typedef
@abstract
Please note that `FBShareDialogHandler` and its related methods have been deprecated, please migrate your
code to use `FBOSIntegratedShareDialogHandler` and its related methods.
*/
typedef void (^FBShareDialogHandler)(FBNativeDialogResult result, NSError *error)
__attribute__((deprecated));
/*!
@class FBNativeDialogs
@abstract
Please note that `FBNativeDialogs` has been deprecated, please migrate your
code to use `FBDialogs`.
*/
@interface FBNativeDialogs : NSObject
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `presentOSIntegratedShareDialogModallyFrom`.
*/
+ (BOOL)presentShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
image:(UIImage*)image
url:(NSURL*)url
handler:(FBShareDialogHandler)handler
__attribute__((deprecated));
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `presentOSIntegratedShareDialogModallyFrom`.
*/
+ (BOOL)presentShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBShareDialogHandler)handler
__attribute__((deprecated));
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `presentOSIntegratedShareDialogModallyFrom`.
*/
+ (BOOL)presentShareDialogModallyFrom:(UIViewController*)viewController
session:(FBSession*)session
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBShareDialogHandler)handler
__attribute__((deprecated));
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `canPresentOSIntegratedShareDialogWithSession`.
*/
+ (BOOL)canPresentShareDialogWithSession:(FBSession*)session __attribute__((deprecated));
@end

View File

@@ -0,0 +1,128 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
@protocol FBGraphPlace;
@protocol FBGraphUser;
/*!
@protocol
@abstract
The `FBOpenGraphAction` protocol is the base protocol for use in posting and retrieving Open Graph actions.
It inherits from the `FBGraphObject` protocol; you may derive custome protocols from `FBOpenGraphAction` in order
implement typed access to your application's custom actions.
@discussion
Represents an Open Graph custom action, to be used directly, or from which to
derive custom action protocols with custom properties.
*/
@protocol FBOpenGraphAction<FBGraphObject>
/*!
@property
@abstract Typed access to action's id
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to action's start time
*/
@property (retain, nonatomic) NSString *start_time;
/*!
@property
@abstract Typed access to action's end time
*/
@property (retain, nonatomic) NSString *end_time;
/*!
@property
@abstract Typed access to action's publication time
*/
@property (retain, nonatomic) NSString *publish_time;
/*!
@property
@abstract Typed access to action's creation time
*/
@property (retain, nonatomic) NSString *created_time;
/*!
@property
@abstract Typed access to action's expiration time
*/
@property (retain, nonatomic) NSString *expires_time;
/*!
@property
@abstract Typed access to action's ref
*/
@property (retain, nonatomic) NSString *ref;
/*!
@property
@abstract Typed access to action's user message
*/
@property (retain, nonatomic) NSString *message;
/*!
@property
@abstract Typed access to action's place
*/
@property (retain, nonatomic) id<FBGraphPlace> place;
/*!
@property
@abstract Typed access to action's tags
*/
@property (retain, nonatomic) NSArray *tags;
/*!
@property
@abstract Typed access to action's image(s)
*/
@property (retain, nonatomic) id image;
/*!
@property
@abstract Typed access to action's from-user
*/
@property (retain, nonatomic) id<FBGraphUser> from;
/*!
@property
@abstract Typed access to action's likes
*/
@property (retain, nonatomic) NSArray *likes;
/*!
@property
@abstract Typed access to action's application
*/
@property (retain, nonatomic) id<FBGraphObject> application;
/*!
@property
@abstract Typed access to action's comments
*/
@property (retain, nonatomic) NSArray *comments;
@end

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2010-present 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 "FBDialogsParams.h"
#import "FBOpenGraphAction.h"
extern NSString *const FBPostObject;
/*!
@class FBOpenGraphActionShareDialogParams
@abstract
This object is used to encapsulate state for parameters to an Open Graph share
dialog that opens in the Facebook app.
*/
@interface FBOpenGraphActionShareDialogParams : FBDialogsParams
/*! @abstract The Open Graph action to be published. */
@property (nonatomic, retain) id<FBOpenGraphAction> action;
/*! @abstract The name of the property representing the primary target of the Open
Graph action, which will be displayed as a preview in the dialog. */
@property (nonatomic, copy) NSString *previewPropertyName;
/*! @abstract The fully qualified type of the Open Graph action. */
@property (nonatomic, copy) NSString *actionType;
@end

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
/*!
@protocol
@abstract
The `FBOpenGraphObject` protocol is the base protocol for use in posting and retrieving Open Graph objects.
It inherits from the `FBGraphObject` protocol; you may derive custome protocols from `FBOpenGraphObject` in order
implement typed access to your application's custom objects.
@discussion
Represents an Open Graph custom object, to be used directly, or from which to
derive custom action protocols with custom properties.
*/
@protocol FBOpenGraphObject<FBGraphObject>
/*!
@property
@abstract Typed access to the object's id
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to the object's type, which is a string in the form mynamespace:mytype
*/
@property (retain, nonatomic) NSString *type;
/*!
@property
@abstract Typed access to object's title
*/
@property (retain, nonatomic) NSString *title;
/*!
@property
@abstract Typed access to the object's image property
*/
@property (retain, nonatomic) id image;
/*!
@property
@abstract Typed access to the object's url property
*/
@property (retain, nonatomic) id url;
/*!
@property
@abstract Typed access to the object's description property
*/
@property (retain, nonatomic) id description;
/*!
@property
@abstract Typed access to action's data, which is a dictionary of custom properties
*/
@property (retain, nonatomic) id<FBGraphObject> data;
@end

View File

@@ -0,0 +1,258 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "FBCacheDescriptor.h"
#import "FBGraphPlace.h"
#import "FBSession.h"
#import "FBViewController.h"
@protocol FBPlacePickerDelegate;
/*!
@class FBPlacePickerViewController
@abstract
The `FBPlacePickerViewController` class creates a controller object that manages
the user interface for displaying and selecting nearby places.
@discussion
When the `FBPlacePickerViewController` view loads it creates a `UITableView` object
where the places near a given location will be displayed. You can access this view
through the `tableView` property.
The place data can be pre-fetched and cached prior to using the view controller. The
cache is setup using an <FBCacheDescriptor> object that can trigger the
data fetch. Any place data requests will first check the cache and use that data.
If the place picker is being displayed cached data will initially be shown before
a fresh copy is retrieved.
The `delegate` property may be set to an object that conforms to the <FBPlacePickerDelegate>
protocol. The `delegate` object will receive updates related to place selection and
data changes. The delegate can also be used to filter the places to display in the
picker.
*/
@interface FBPlacePickerViewController : FBViewController
/*!
@abstract
Returns an outlet for the spinner used in the view controller.
*/
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner;
/*!
@abstract
Returns an outlet for the table view managed by the view controller.
*/
@property (nonatomic, retain) IBOutlet UITableView *tableView;
/*!
@abstract
Addtional fields to fetch when making the Graph API call to get place data.
*/
@property (nonatomic, copy) NSSet *fieldsForRequest;
/*!
@abstract
A Boolean value that indicates whether place profile pictures are displayed.
*/
@property (nonatomic) BOOL itemPicturesEnabled;
/*!
@abstract
The coordinates to use for place discovery.
*/
@property (nonatomic) CLLocationCoordinate2D locationCoordinate;
/*!
@abstract
The radius to use for place discovery.
*/
@property (nonatomic) NSInteger radiusInMeters;
/*!
@abstract
The maximum number of places to fetch.
*/
@property (nonatomic) NSInteger resultsLimit;
/*!
@abstract
The search words used to narrow down the results returned.
*/
@property (nonatomic, copy) NSString *searchText;
/*!
@abstract
The session that is used in the request for place data.
*/
@property (nonatomic, retain) FBSession *session;
/*!
@abstract
The place that is currently selected in the view. This is nil
if nothing is selected.
*/
@property (nonatomic, retain, readonly) id<FBGraphPlace> selection;
/*!
@abstract
Clears the current selection, so the picker is ready for a fresh use.
*/
- (void)clearSelection;
/*!
@abstract
Initializes a place picker view controller.
*/
- (id)init;
/*!
@abstract
Initializes a place picker view controller.
@param aDecoder An unarchiver object.
*/
- (id)initWithCoder:(NSCoder *)aDecoder;
/*!
@abstract
Initializes a place picker view controller.
@param nibNameOrNil The name of the nib file to associate with the view controller. The nib file name should not contain any leading path information. If you specify nil, the nibName property is set to nil.
@param nibBundleOrNil The bundle in which to search for the nib file. This method looks for the nib file in the bundle's language-specific project directories first, followed by the Resources directory. If nil, this method looks for the nib file in the main bundle.
*/
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
/*!
@abstract
Configures the properties used in the caching data queries.
@discussion
Cache descriptors are used to fetch and cache the data used by the view controller.
If the view controller finds a cached copy of the data, it will
first display the cached content then fetch a fresh copy from the server.
@param cacheDescriptor The <FBCacheDescriptor> containing the cache query properties.
*/
- (void)configureUsingCachedDescriptor:(FBCacheDescriptor*)cacheDescriptor;
/*!
@abstract
Initiates a query to get place data the first time or in response to changes in
the search criteria, filter, or location information.
@discussion
A cached copy will be returned if available. The cached view is temporary until a fresh copy is
retrieved from the server. It is legal to call this more than once.
*/
- (void)loadData;
/*!
@abstract
Updates the view locally without fetching data from the server or from cache.
@discussion
Use this if the filter properties change. This may affect the order or
display of information.
*/
- (void)updateView;
/*!
@method
@abstract
Creates a cache descriptor with additional fields and a profile ID for use with the
`FBPlacePickerViewController` object.
@discussion
An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
the view controller. It may also be used to configure the `FBPlacePickerViewController`
object.
@param locationCoordinate The coordinates to use for place discovery.
@param radiusInMeters The radius to use for place discovery.
@param searchText The search words used to narrow down the results returned.
@param resultsLimit The maximum number of places to fetch.
@param fieldsForRequest Addtional fields to fetch when making the Graph API call to get place data.
*/
+ (FBCacheDescriptor*)cacheDescriptorWithLocationCoordinate:(CLLocationCoordinate2D)locationCoordinate
radiusInMeters:(NSInteger)radiusInMeters
searchText:(NSString*)searchText
resultsLimit:(NSInteger)resultsLimit
fieldsForRequest:(NSSet*)fieldsForRequest;
@end
/*!
@protocol
@abstract
The `FBPlacePickerDelegate` protocol defines the methods used to receive event
notifications and allow for deeper control of the <FBPlacePickerViewController>
view.
*/
@protocol FBPlacePickerDelegate <FBViewControllerDelegate>
@optional
/*!
@abstract
Tells the delegate that data has been loaded.
@discussion
The <FBPlacePickerViewController> object's `tableView` property is automatically
reloaded when this happens. However, if another table view, for example the
`UISearchBar` is showing data, then it may also need to be reloaded.
@param placePicker The place picker view controller whose data changed.
*/
- (void)placePickerViewControllerDataDidChange:(FBPlacePickerViewController *)placePicker;
/*!
@abstract
Tells the delegate that the selection has changed.
@param placePicker The place picker view controller whose selection changed.
*/
- (void)placePickerViewControllerSelectionDidChange:(FBPlacePickerViewController *)placePicker;
/*!
@abstract
Asks the delegate whether to include a place in the list.
@discussion
This can be used to implement a search bar that filters the places list.
@param placePicker The place picker view controller that is requesting this information.
@param place An <FBGraphPlace> object representing the place.
*/
- (BOOL)placePickerViewController:(FBPlacePickerViewController *)placePicker
shouldIncludePlace:(id <FBGraphPlace>)place;
/*!
@abstract
Called if there is a communication error.
@param placePicker The place picker view controller that encountered the error.
@param error An error object containing details of the error.
*/
- (void)placePickerViewController:(FBPlacePickerViewController *)placePicker
handleError:(NSError *)error;
@end

View File

@@ -0,0 +1,80 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
/*!
@typedef FBProfilePictureCropping enum
@abstract
Type used to specify the cropping treatment of the profile picture.
@discussion
*/
typedef enum {
/*! Square (default) - the square version that the Facebook user defined. */
FBProfilePictureCroppingSquare = 0,
/*! Original - the original profile picture, as uploaded. */
FBProfilePictureCroppingOriginal = 1
} FBProfilePictureCropping;
/*!
@class
@abstract
An instance of `FBProfilePictureView` is used to display a profile picture.
The default behavior of this control is to center the profile picture
in the view and shrinks it, if necessary, to the view's bounds, preserving the aspect ratio. The smallest
possible image is downloaded to ensure that scaling up never happens. Resizing the view may result in
a different size of the image being loaded. Canonical image sizes are documented in the "Pictures" section
of https://developers.facebook.com/docs/reference/api.
*/
@interface FBProfilePictureView : UIView
/*!
@abstract
The Facebook ID of the user, place or object for which a picture should be fetched and displayed.
*/
@property (copy, nonatomic) NSString* profileID;
/*!
@abstract
The cropping to use for the profile picture.
*/
@property (nonatomic) FBProfilePictureCropping pictureCropping;
/*!
@abstract
Initializes and returns a profile view object.
*/
- (id)init;
/*!
@abstract
Initializes and returns a profile view object for the given Facebook ID and cropping.
@param profileID The Facebook ID of the user, place or object for which a picture should be fetched and displayed.
@param pictureCropping The cropping to use for the profile picture.
*/
- (id)initWithProfileID:(NSString*)profileID
pictureCropping:(FBProfilePictureCropping)pictureCropping;
@end

View File

@@ -0,0 +1,672 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "FBGraphObject.h"
#import "FBOpenGraphAction.h"
#import "FBOpenGraphObject.h"
#import "FBRequestConnection.h"
/*! The base URL used for graph requests */
extern NSString* const FBGraphBasePath __attribute__((deprecated));
// up-front decl's
@protocol FBRequestDelegate;
@class FBSession;
@class UIImage;
/*!
@typedef FBRequestState
@abstract
Deprecated - do not use in new code.
@discussion
FBRequestState is retained from earlier versions of the SDK to give existing
apps time to remove dependency on this.
@deprecated
*/
typedef NSUInteger FBRequestState __attribute__((deprecated));
/*!
@class FBRequest
@abstract
The `FBRequest` object is used to setup and manage requests to Facebook Graph
and REST APIs. This class provides helper methods that simplify the connection
and response handling.
@discussion
An <FBSession> object is required for all authenticated uses of `FBRequest`.
Requests that do not require an unauthenticated user are also supported and
do not require an <FBSession> object to be passed in.
An instance of `FBRequest` represents the arguments and setup for a connection
to Facebook. After creating an `FBRequest` object it can be used to setup a
connection to Facebook through the <FBRequestConnection> object. The
<FBRequestConnection> object is created to manage a single connection. To
cancel a connection use the instance method in the <FBRequestConnection> class.
An `FBRequest` object may be reused to issue multiple connections to Facebook.
However each <FBRequestConnection> instance will manage one connection.
Class and instance methods prefixed with **start* ** can be used to perform the
request setup and initiate the connection in a single call.
*/
@interface FBRequest : NSObject {
@private
id<FBRequestDelegate> _delegate;
NSString* _url;
NSURLConnection* _connection;
NSMutableData* _responseText;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
FBRequestState _state;
#pragma GCC diagnostic pop
NSError* _error;
BOOL _sessionDidExpire;
id<FBGraphObject> _graphObject;
}
/*!
@methodgroup Creating a request
@method
Calls <initWithSession:graphPath:parameters:HTTPMethod:> with the default parameters.
*/
- (id)init;
/*!
@method
Calls <initWithSession:graphPath:parameters:HTTPMethod:> with default parameters
except for the ones provided to this method.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
*/
- (id)initWithSession:(FBSession*)session
graphPath:(NSString *)graphPath;
/*!
@method
@abstract
Initializes an `FBRequest` object for a Graph API request call.
@discussion
Note that this only sets properties on the `FBRequest` object.
To send the request, initialize an <FBRequestConnection> object, add this request,
and send <[FBRequestConnection start]>. See other methods on this
class for shortcuts to simplify this process.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param parameters The parameters for the request. A value of nil sends only the automatically handled
parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. The default is value of nil implies a GET.
*/
- (id)initWithSession:(FBSession*)session
graphPath:(NSString *)graphPath
parameters:(NSDictionary *)parameters
HTTPMethod:(NSString *)HTTPMethod;
/*!
@method
@abstract
Initialize a `FBRequest` object that will do a graph request.
@discussion
Note that this only sets properties on the `FBRequest`.
To send the request, initialize a <FBRequestConnection>, add this request,
and send <[FBRequestConnection start]>. See other methods on this
class for shortcuts to simplify this process.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param graphObject An object or open graph action to post.
*/
- (id)initForPostWithSession:(FBSession*)session
graphPath:(NSString *)graphPath
graphObject:(id<FBGraphObject>)graphObject;
/*!
@method
@abstract
Initialize a `FBRequest` object that will do a rest API request.
@discussion
Prefer to use graph requests instead of this where possible.
Note that this only sets properties on the `FBRequest`.
To send the request, initialize a <FBRequestConnection>, add this request,
and send <[FBRequestConnection start]>. See other methods on this
class for shortcuts to simplify this process.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param restMethod A valid REST API method.
@param parameters The parameters for the request. A value of nil sends only the automatically handled
parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. The default is value of nil implies a GET.
*/
- (id)initWithSession:(FBSession*)session
restMethod:(NSString *)restMethod
parameters:(NSDictionary *)parameters
HTTPMethod:(NSString *)HTTPMethod;
/*!
@abstract
The parameters for the request.
@discussion
May be used to read the parameters that were automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
`NSString` parameters are used to generate URL parameter values or JSON
parameters. `NSData` and `UIImage` parameters are added as attachments
to the HTTP body and referenced by name in the URL and/or JSON.
*/
@property (nonatomic, retain, readonly) NSMutableDictionary *parameters;
/*!
@abstract
The <FBSession> session object to use for the request.
@discussion
May be used to read the session that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, retain) FBSession *session;
/*!
@abstract
The Graph API endpoint to use for the request, for example "me".
@discussion
May be used to read the Graph API endpoint that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, copy) NSString *graphPath;
/*!
@abstract
A valid REST API method.
@discussion
May be used to read the REST method that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
Use the Graph API equivalent of the API if it exists as the REST API
method is deprecated if there is a Graph API equivalent.
*/
@property (nonatomic, copy) NSString *restMethod;
/*!
@abstract
The HTTPMethod to use for the request, for example "GET" or "POST".
@discussion
May be used to read the HTTP method that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, copy) NSString *HTTPMethod;
/*!
@abstract
The graph object to post with the request.
@discussion
May be used to read the graph object that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, retain) id<FBGraphObject> graphObject;
/*!
@methodgroup Instance methods
*/
/*!
@method
@abstract
Starts a connection to the Facebook API.
@discussion
This is used to start an API call to Facebook and call the block when the
request completes with a success, error, or cancel.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
The handler will be invoked on the main thread.
*/
- (FBRequestConnection*)startWithCompletionHandler:(FBRequestHandler)handler;
/*!
@methodgroup FBRequestConnection start methods
@abstract
These methods start an <FBRequestConnection>.
@discussion
These methods simplify the process of preparing a request and starting
the connection. The methods handle initializing an `FBRequest` object,
initializing a <FBRequestConnection> object, adding the `FBRequest`
object to the to the <FBRequestConnection>, and finally starting the
connection.
*/
/*!
@methodgroup FBRequest factory methods
@abstract
These methods initialize a `FBRequest` for common scenarios.
@discussion
These simplify the process of preparing a request to send. These
initialize a `FBRequest` based on strongly typed parameters that are
specific to the scenario.
These method do not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
*/
// request*
//
// Summary:
// Helper methods used to create common request objects which can be used to create single or batch connections
//
// session: - the session object representing the identity of the
// Facebook user making the request; nil implies an
// unauthenticated request; default=nil
/*!
@method
@abstract
Creates a request representing a Graph API call to the "me" endpoint, using the active session.
@discussion
Simplifies preparing a request to retrieve the user's identity.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
A successful Graph API call will return an <FBGraphUser> object representing the
user's identity.
Note you may change the session property after construction if a session other than
the active session is preferred.
*/
+ (FBRequest *)requestForMe;
/*!
@method
@abstract
Creates a request representing a Graph API call to the "me/friends" endpoint using the active session.
@discussion
Simplifies preparing a request to retrieve the user's friends.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
A successful Graph API call will return an array of <FBGraphUser> objects representing the
user's friends.
*/
+ (FBRequest *)requestForMyFriends;
/*!
@method
@abstract
Creates a request representing a Graph API call to upload a photo to the app's album using the active session.
@discussion
Simplifies preparing a request to post a photo.
To post a photo to a specific album, get the `FBRequest` returned from this method
call, then modify the request parameters by adding the album ID to an "album" key.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param photo A `UIImage` for the photo to upload.
*/
+ (FBRequest *)requestForUploadPhoto:(UIImage *)photo;
/*!
@method
@abstract
Creates a request representing a status update.
@discussion
Simplifies preparing a request to post a status update.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param message The message to post.
*/
+ (FBRequest *)requestForPostStatusUpdate:(NSString *)message;
/*!
@method
@abstract
Creates a request representing a status update.
@discussion
Simplifies preparing a request to post a status update.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param message The message to post.
@param place The place to checkin with, or nil. Place may be an fbid or a
graph object representing a place.
@param tags Array of friends to tag in the status update, each element
may be an fbid or a graph object representing a user.
*/
+ (FBRequest *)requestForPostStatusUpdate:(NSString *)message
place:(id)place
tags:(id<NSFastEnumeration>)tags;
/*!
@method
@abstract
Creates a request representing a Graph API call to the "search" endpoint
for a given location using the active session.
@discussion
Simplifies preparing a request to search for places near a coordinate.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
A successful Graph API call will return an array of <FBGraphPlace> objects representing
the nearby locations.
@param coordinate The search coordinates.
@param radius The search radius in meters.
@param limit The maxiumum number of results to return. It is
possible to receive fewer than this because of the radius and because of server limits.
@param searchText The text to use in the query to narrow the set of places
returned.
*/
+ (FBRequest *)requestForPlacesSearchAtCoordinate:(CLLocationCoordinate2D)coordinate
radiusInMeters:(NSInteger)radius
resultsLimit:(NSInteger)limit
searchText:(NSString*)searchText;
/*!
@method
@abstract
Creates a request representing the Graph API call to retrieve a Custom Audience "thirdy party ID" for the app's Facebook user.
Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with,
and then use the resultant Custom Audience to target ads.
@param session The FBSession to use to establish the user's identity for users logged into Facebook through this app.
If `nil`, then the activeSession is used.
@discussion
This method will throw an exception if <[FBSettings defaultAppID]> is `nil`. The appID won't be nil when the pList
includes the appID, or if it's explicitly set.
The JSON in the request's response will include an "custom_audience_third_party_id" key/value pair, with the value being the ID retrieved.
This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID.
Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior
across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
The ID retrieved represents the Facebook user identified in the following way: if the specified session (or activeSession if the specified
session is `nil`) is open, the ID will represent the user associated with the activeSession; otherwise the ID will represent the user logged into the
native Facebook app on the device. If there is no native Facebook app, no one is logged into it, or the user has opted out
at the iOS level from ad tracking, then a `nil` ID will be returned.
This method returns `nil` if either the user has opted-out (via iOS) from Ad Tracking, the app itself has limited event usage
via the `[FBAppEvents setLimitEventUsage]` flag, or a specific Facebook user cannot be identified.
*/
+ (FBRequest *)requestForCustomAudienceThirdPartyID:(FBSession *)session;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to make a Graph API call for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param graphPath The Graph API endpoint to use for the request, for example "me".
*/
+ (FBRequest *)requestForGraphPath:(NSString*)graphPath;
/*!
@method
@abstract
Creates request representing a DELETE to a object.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param object This can be an NSString, NSNumber or NSDictionary representing an object to delete
*/
+ (FBRequest *)requestForDeleteObject:(id)object;
/*!
@method
@abstract
Creates a request representing a POST for a graph object.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param graphObject An object or open graph action to post.
@discussion This method is typically used for posting an open graph action. If you are only
posting an open graph object (without an action), consider using `requestForPostOpenGraphObject:`
*/
+ (FBRequest *)requestForPostWithGraphPath:(NSString*)graphPath
graphObject:(id<FBGraphObject>)graphObject;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to make a Graph API call for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param parameters The parameters for the request. A value of nil sends only the automatically handled parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. A nil value implies a GET.
*/
+ (FBRequest *)requestWithGraphPath:(NSString*)graphPath
parameters:(NSDictionary*)parameters
HTTPMethod:(NSString*)HTTPMethod;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to create a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param object The Open Graph object to create. Some common expected fields include "title", "image", "url", etc.
*/
+ (FBRequest *)requestForPostOpenGraphObject:(id<FBOpenGraphObject>)object;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to create a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param type The fully-specified Open Graph object type (e.g., my_app_namespace:my_object_name)
@param title The title of the Open Graph object.
@param image The link to an image to be associated with the Open Graph object.
@param url The url to be associated with the Open Graph object.
@param description The description to be associated with the object.
@param objectProperties Any additional properties for the Open Graph object.
*/
+ (FBRequest *)requestForPostOpenGraphObjectWithType:(NSString *)type
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to update a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param object The Open Graph object to update the existing object with.
*/
+ (FBRequest *)requestForUpdateOpenGraphObject:(id<FBOpenGraphObject>)object;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to update a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param objectId The id of the Open Graph object to update.
@param title The updated title of the Open Graph object.
@param image The updated link to an image to be associated with the Open Graph object.
@param url The updated url to be associated with the Open Graph object.
@param description The updated description of the Open Graph object.
@param objectProperties Any additional properties to update for the Open Graph object.
*/
+ (FBRequest *)requestForUpdateOpenGraphObjectWithId:(id)objectId
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to upload an image
to create a staging resource. Staging resources allow you to post binary data
such as images, in preparation for a post of an open graph object or action
which references the image. The URI returned when uploading a staging resource
may be passed as the image property for an open graph object or action.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param image A `UIImage` for the image to upload.
*/
+ (FBRequest *)requestForUploadStagingResourceWithImage:(UIImage *)image;
@end

View File

@@ -0,0 +1,626 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "FBGraphObject.h"
// up-front decl's
@class FBRequest;
@class FBRequestConnection;
@class FBSession;
@class UIImage;
/*!
@attribute beta true
@typedef FBRequestConnectionErrorBehavior enum
@abstract Describes what automatic error handling behaviors to provide (if any).
@discussion This is a bitflag enum that can be composed of different values.
See FBError.h and FBErrorUtility.h for error category and user message details.
*/
typedef enum {
/*! The default behavior of none */
FBRequestConnectionErrorBehaviorNone = 0,
/*! This will retry any requests whose error category is classified as `FBErrorCategoryRetry`.
If the retry fails, the normal handler is invoked. */
FBRequestConnectionErrorBehaviorRetry = 1,
/*! This will automatically surface any SDK provided userMessage (at most one), after
retry attempts, but before any reconnects are tried. The alert will have one button
whose text can be localized with the key "FBE:AlertMessageButton".
You should not display your own alert views in your request handler when specifying this
behavior.
*/
FBRequestConnectionErrorBehaviorAlertUser = 2,
/*! This will automatically reconnect a session if the request failed due to an invalid token
that would otherwise close the session (such as an expired token or password change). Note
this will NOT reconnect a session if the user had uninstalled the app, or if the user had
disabled the app's slider in their privacy settings (in cases of iOS 6 system auth).
If the session is reconnected, this will transition the session state to FBSessionStateTokenExtended
which will invoke any state change handlers. Otherwise, the session is closed as normal.
This behavior should not be used if the FBRequestConnection contains multiple
session instances. Further, when this behavior is used, you must not request new permissions
for the session until the connection is completed.
Lastly, you should avoid using additional FBRequestConnections with the same session because
that will be subject to race conditions.
*/
FBRequestConnectionErrorBehaviorReconnectSession = 4,
} FBRequestConnectionErrorBehavior;
/*!
Normally requests return JSON data that is parsed into a set of `NSDictionary`
and `NSArray` objects.
When a request returns a non-JSON response, that response is packaged in
a `NSDictionary` using FBNonJSONResponseProperty as the key and the literal
response as the value.
*/
extern NSString *const FBNonJSONResponseProperty;
/*!
@typedef FBRequestHandler
@abstract
A block that is passed to addRequest to register for a callback with the results of that
request once the connection completes.
@discussion
Pass a block of this type when calling addRequest. This will be called once
the request completes. The call occurs on the UI thread.
@param connection The `FBRequestConnection` that sent the request.
@param result The result of the request. This is a translation of
JSON data to `NSDictionary` and `NSArray` objects. This
is nil if there was an error.
@param error The `NSError` representing any error that occurred.
*/
typedef void (^FBRequestHandler)(FBRequestConnection *connection,
id result,
NSError *error);
/*!
@class FBRequestConnection
@abstract
The `FBRequestConnection` represents a single connection to Facebook to service a request.
@discussion
The request settings are encapsulated in a reusable <FBRequest> object. The
`FBRequestConnection` object encapsulates the concerns of a single communication
e.g. starting a connection, canceling a connection, or batching requests.
*/
@interface FBRequestConnection : NSObject
/*!
@methodgroup Creating a request
*/
/*!
@method
Calls <initWithTimeout:> with a default timeout of 180 seconds.
*/
- (id)init;
/*!
@method
@abstract
`FBRequestConnection` objects are used to issue one or more requests as a single
request/response connection with Facebook.
@discussion
For a single request, the usual method for creating an `FBRequestConnection`
object is to call one of the **start* ** methods on <FBRequest>. However, it is
allowable to init an `FBRequestConnection` object directly, and call
<addRequest:completionHandler:> to add one or more request objects to the
connection, before calling start.
Note that if requests are part of a batch, they must have an open
FBSession that has an access token associated with it. Alternatively a default App ID
must be set either in the plist or through an explicit call to <[FBSession defaultAppID]>.
@param timeout The `NSTimeInterval` (seconds) to wait for a response before giving up.
*/
- (id)initWithTimeout:(NSTimeInterval)timeout;
// properties
/*!
@abstract
The request that will be sent to the server.
@discussion
This property can be used to create a `NSURLRequest` without using
`FBRequestConnection` to send that request. It is legal to set this property
in which case the provided `NSMutableURLRequest` will be used instead. However,
the `NSMutableURLRequest` must result in an appropriate response. Furthermore, once
this property has been set, no more <FBRequest> objects can be added to this
`FBRequestConnection`.
*/
@property (nonatomic, retain, readwrite) NSMutableURLRequest *urlRequest;
/*!
@abstract
The raw response that was returned from the server. (readonly)
@discussion
This property can be used to inspect HTTP headers that were returned from
the server.
The property is nil until the request completes. If there was a response
then this property will be non-nil during the FBRequestHandler callback.
*/
@property (nonatomic, retain, readonly) NSHTTPURLResponse *urlResponse;
/*!
@attribute beta true
@abstract Set the automatic error handling behaviors.
@discussion
This must be set before any requests are added.
When using retry behaviors, note the FBRequestConnection instance
passed to the FBRequestHandler may be a different instance that the
one the requests were originally started on.
*/
@property (nonatomic, assign) FBRequestConnectionErrorBehavior errorBehavior;
/*!
@methodgroup Adding requests
*/
/*!
@method
@abstract
This method adds an <FBRequest> object to this connection.
@discussion
The completion handler is retained until the block is called upon the
completion or cancellation of the connection.
@param request A request to be included in the round-trip when start is called.
@param handler A handler to call back when the round-trip completes or times out.
The handler will be invoked on the main thread.
*/
- (void)addRequest:(FBRequest*)request
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
This method adds an <FBRequest> object to this connection.
@discussion
The completion handler is retained until the block is called upon the
completion or cancellation of the connection. This request can be named
to allow for using the request's response in a subsequent request.
@param request A request to be included in the round-trip when start is called.
@param handler A handler to call back when the round-trip completes or times out.
The handler will be invoked on the main thread.
@param name An optional name for this request. This can be used to feed
the results of one request to the input of another <FBRequest> in the same
`FBRequestConnection` as described in
[Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
*/
- (void)addRequest:(FBRequest*)request
completionHandler:(FBRequestHandler)handler
batchEntryName:(NSString*)name;
/*!
@method
@abstract
This method adds an <FBRequest> object to this connection.
@discussion
The completion handler is retained until the block is called upon the
completion or cancellation of the connection. This request can be named
to allow for using the request's response in a subsequent request.
@param request A request to be included in the round-trip when start is called.
@param handler A handler to call back when the round-trip completes or times out.
@param batchParameters The optional dictionary of parameters to include for this request
as described in [Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
Examples include "depends_on", "name", or "omit_response_on_success".
*/
- (void)addRequest:(FBRequest*)request
completionHandler:(FBRequestHandler)handler
batchParameters:(NSDictionary*)batchParameters;
/*!
@methodgroup Instance methods
*/
/*!
@method
@abstract
This method starts a connection with the server and is capable of handling all of the
requests that were added to the connection.
@discussion
Errors are reported via the handler callback, even in cases where no
communication is attempted by the implementation of `FBRequestConnection`. In
such cases multiple error conditions may apply, and if so the following
priority (highest to lowest) is used:
- `FBRequestConnectionInvalidRequestKey` -- this error is reported when an
<FBRequest> cannot be encoded for transmission.
- `FBRequestConnectionInvalidBatchKey` -- this error is reported when any
request in the connection cannot be encoded for transmission with the batch.
In this scenario all requests fail.
This method cannot be called twice for an `FBRequestConnection` instance.
*/
- (void)start;
/*!
@method
@abstract
Signals that a connection should be logically terminated as the
application is no longer interested in a response.
@discussion
Synchronously calls any handlers indicating the request was cancelled. Cancel
does not guarantee that the request-related processing will cease. It
does promise that all handlers will complete before the cancel returns. A call to
cancel prior to a start implies a cancellation of all requests associated
with the connection.
*/
- (void)cancel;
/*!
@method
@abstract
Simple method to make a graph API request for user info (/me), creates an <FBRequest>
then uses an <FBRequestConnection> object to start the connection with Facebook. The
request uses the active session represented by `[FBSession activeSession]`.
See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForMeWithCompletionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API request for user friends (/me/friends), creates an <FBRequest>
then uses an <FBRequestConnection> object to start the connection with Facebook. The
request uses the active session represented by `[FBSession activeSession]`.
See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForMyFriendsWithCompletionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API post of a photo. The request
uses the active session represented by `[FBSession activeSession]`.
@param photo A `UIImage` for the photo to upload.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForUploadPhoto:(UIImage *)photo
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API post of a status update. The request
uses the active session represented by `[FBSession activeSession]`.
@param message The message to post.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API post of a status update. The request
uses the active session represented by `[FBSession activeSession]`.
@param message The message to post.
@param place The place to checkin with, or nil. Place may be an fbid or a
graph object representing a place.
@param tags Array of friends to tag in the status update, each element
may be an fbid or a graph object representing a user.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
place:(id)place
tags:(id<NSFastEnumeration>)tags
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Starts a request representing a Graph API call to the "search" endpoint
for a given location using the active session.
@discussion
Simplifies starting a request to search for places near a coordinate.
This method creates the necessary <FBRequest> object and initializes and
starts an <FBRequestConnection> object. A successful Graph API call will
return an array of <FBGraphPlace> objects representing the nearby locations.
@param coordinate The search coordinates.
@param radius The search radius in meters.
@param limit The maxiumum number of results to return. It is
possible to receive fewer than this because of the
radius and because of server limits.
@param searchText The text to use in the query to narrow the set of places
returned.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForPlacesSearchAtCoordinate:(CLLocationCoordinate2D)coordinate
radiusInMeters:(NSInteger)radius
resultsLimit:(NSInteger)limit
searchText:(NSString*)searchText
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Starts a request representing the Graph API call to retrieve a Custom Audience "third party ID" for the app's Facebook user.
Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with,
and then use the resultant Custom Audience to target ads.
@param session The FBSession to use to establish the user's identity for users logged into Facebook through this app.
If `nil`, then the activeSession is used.
@discussion
This method will throw an exception if <[FBSettings defaultAppID]> is `nil`. The appID won't be nil when the pList
includes the appID, or if it's explicitly set.
The JSON in the request's response will include an "custom_audience_third_party_id" key/value pair, with the value being the ID retrieved.
This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID.
Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior
across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
The ID retrieved represents the Facebook user identified in the following way: if the specified session (or activeSession if the specified
session is `nil`) is open, the ID will represent the user associated with the activeSession; otherwise the ID will represent the user logged into the
native Facebook app on the device. If there is no native Facebook app, no one is logged into it, or the user has opted out
at the iOS level from ad tracking, then a `nil` ID will be returned.
This method returns `nil` if either the user has opted-out (via iOS) from Ad Tracking, the app itself has limited event usage
via the `[FBAppEvents setLimitEventUsage]` flag, or a specific Facebook user cannot be identified.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForCustomAudienceThirdPartyID:(FBSession *)session
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API request, creates an <FBRequest> object for HTTP GET,
then uses an <FBRequestConnection> object to start the connection with Facebook. The
request uses the active session represented by `[FBSession activeSession]`.
See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startWithGraphPath:(NSString*)graphPath
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to delete an object using the graph API, creates an <FBRequest> object for
HTTP DELETE, then uses an <FBRequestConnection> object to start the connection with Facebook.
The request uses the active session represented by `[FBSession activeSession]`.
@param object The object to delete, may be an NSString or NSNumber representing an fbid or an NSDictionary with an id property
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForDeleteObject:(id)object
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to post an object using the graph API, creates an <FBRequest> object for
HTTP POST, then uses <FBRequestConnection> to start a connection with Facebook. The request uses
the active session represented by `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param graphObject An object or open graph action to post.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
@discussion This method is typically used for posting an open graph action. If you are only
posting an open graph object (without an action), consider using `startForPostOpenGraphObject:completionHandler:`
*/
+ (FBRequestConnection*)startForPostWithGraphPath:(NSString*)graphPath
graphObject:(id<FBGraphObject>)graphObject
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` object for a Graph API call, instantiate an
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. Use this method for
specifying the request parameters and HTTP Method. The request uses
the active session represented by `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param parameters The parameters for the request. A value of nil sends only the automatically handled parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. A nil value implies a GET.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startWithGraphPath:(NSString*)graphPath
parameters:(NSDictionary*)parameters
HTTPMethod:(NSString*)HTTPMethod
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for creating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param object The Open Graph object to create. Some common expected fields include "title", "image", "url", etc.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForPostOpenGraphObject:(id<FBOpenGraphObject>)object
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for creating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param type The fully-specified Open Graph object type (e.g., my_app_namespace:my_object_name)
@param title The title of the Open Graph object.
@param image The link to an image to be associated with the Open Graph object.
@param url The url to be associated with the Open Graph object.
@param description The description for the object.
@param objectProperties Any additional properties for the Open Graph object.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForPostOpenGraphObjectWithType:(NSString *)type
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for updating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param object The Open Graph object to update the existing object with.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForUpdateOpenGraphObject:(id<FBOpenGraphObject>)object
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for updating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param objectId The id of the Open Graph object to update.
@param title The updated title of the Open Graph object.
@param image The updated link to an image to be associated with the Open Graph object.
@param url The updated url to be associated with the Open Graph object.
@param description The object's description.
@param objectProperties Any additional properties to update for the Open Graph object.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection *)startForUpdateOpenGraphObjectWithId:(id)objectId
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Starts a request connection to upload an image
to create a staging resource. Staging resources allow you to post binary data
such as images, in preparation for a post of an open graph object or action
which references the image. The URI returned when uploading a staging resource
may be passed as the value for the image property of an open graph object or action.
@discussion
This method simplifies the preparation of a Graph API call be creating the FBRequest
object and starting the request connection with a single method
@param image A `UIImage` for the image to upload.
@param handler The handler block to call when the request completes.
*/
+ (FBRequestConnection *)startForUploadStagingResourceWithImage:(UIImage *)image
completionHandler:(FBRequestHandler)handler;
@end

View File

@@ -0,0 +1,785 @@
/*
* Copyright 2010-present 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 <Accounts/Accounts.h>
#import <Foundation/Foundation.h>
// up-front decl's
@class FBAccessTokenData;
@class FBSession;
@class FBSessionTokenCachingStrategy;
#define FB_SESSIONSTATETERMINALBIT (1 << 8)
#define FB_SESSIONSTATEOPENBIT (1 << 9)
/*
* Constants used by NSNotificationCenter for active session notification
*/
/*! NSNotificationCenter name indicating that a new active session was set */
extern NSString *const FBSessionDidSetActiveSessionNotification;
/*! NSNotificationCenter name indicating that an active session was unset */
extern NSString *const FBSessionDidUnsetActiveSessionNotification;
/*! NSNotificationCenter name indicating that the active session is open */
extern NSString *const FBSessionDidBecomeOpenActiveSessionNotification;
/*! NSNotificationCenter name indicating that there is no longer an open active session */
extern NSString *const FBSessionDidBecomeClosedActiveSessionNotification;
/*!
@typedef FBSessionState enum
@abstract Passed to handler block each time a session state changes
@discussion
*/
typedef enum {
/*! One of two initial states indicating that no valid cached token was found */
FBSessionStateCreated = 0,
/*! One of two initial session states indicating that a cached token was loaded;
when a session is in this state, a call to open* will result in an open session,
without UX or app-switching*/
FBSessionStateCreatedTokenLoaded = 1,
/*! One of three pre-open session states indicating that an attempt to open the session
is underway*/
FBSessionStateCreatedOpening = 2,
/*! Open session state indicating user has logged in or a cached token is available */
FBSessionStateOpen = 1 | FB_SESSIONSTATEOPENBIT,
/*! Open session state indicating token has been extended */
FBSessionStateOpenTokenExtended = 2 | FB_SESSIONSTATEOPENBIT,
/*! Closed session state indicating that a login attempt failed */
FBSessionStateClosedLoginFailed = 1 | FB_SESSIONSTATETERMINALBIT, // NSError obj w/more info
/*! Closed session state indicating that the session was closed, but the users token
remains cached on the device for later use */
FBSessionStateClosed = 2 | FB_SESSIONSTATETERMINALBIT, // "
} FBSessionState;
/*! helper macro to test for states that imply an open session */
#define FB_ISSESSIONOPENWITHSTATE(state) (0 != (state & FB_SESSIONSTATEOPENBIT))
/*! helper macro to test for states that are terminal */
#define FB_ISSESSIONSTATETERMINAL(state) (0 != (state & FB_SESSIONSTATETERMINALBIT))
/*!
@typedef FBSessionLoginBehavior enum
@abstract
Passed to open to indicate whether Facebook Login should allow for fallback to be attempted.
@discussion
Facebook Login authorizes the application to act on behalf of the user, using the user's
Facebook account. Usually a Facebook Login will rely on an account maintained outside of
the application, by the native Facebook application, the browser, or perhaps the device
itself. This avoids the need for a user to enter their username and password directly, and
provides the most secure and lowest friction way for a user to authorize the application to
interact with Facebook. If a Facebook Login is not possible, a fallback Facebook Login may be
attempted, where the user is prompted to enter their credentials in a web-view hosted directly
by the application.
The `FBSessionLoginBehavior` enum specifies whether to allow fallback, disallow fallback, or
force fallback login behavior. Most applications will use the default, which attempts a normal
Facebook Login, and only falls back if needed. In rare cases, it may be preferable to disallow
fallback Facebook Login completely, or to force a fallback login.
*/
typedef enum {
/*! Attempt Facebook Login, ask user for credentials if necessary */
FBSessionLoginBehaviorWithFallbackToWebView = 0,
/*! Attempt Facebook Login, no direct request for credentials will be made */
FBSessionLoginBehaviorWithNoFallbackToWebView = 1,
/*! Only attempt WebView Login; ask user for credentials */
FBSessionLoginBehaviorForcingWebView = 2,
/*! Attempt Facebook Login, prefering system account and falling back to fast app switch if necessary */
FBSessionLoginBehaviorUseSystemAccountIfPresent = 3,
} FBSessionLoginBehavior;
/*!
@typedef FBSessionDefaultAudience enum
@abstract
Passed to open to indicate which default audience to use for sessions that post data to Facebook.
@discussion
Certain operations such as publishing a status or publishing a photo require an audience. When the user
grants an application permission to perform a publish operation, a default audience is selected as the
publication ceiling for the application. This enumerated value allows the application to select which
audience to ask the user to grant publish permission for.
*/
typedef enum {
/*! No audience needed; this value is useful for cases where data will only be read from Facebook */
FBSessionDefaultAudienceNone = 0,
/*! Indicates that only the user is able to see posts made by the application */
FBSessionDefaultAudienceOnlyMe = 10,
/*! Indicates that the user's friends are able to see posts made by the application */
FBSessionDefaultAudienceFriends = 20,
/*! Indicates that all Facebook users are able to see posts made by the application */
FBSessionDefaultAudienceEveryone = 30,
} FBSessionDefaultAudience;
/*!
@typedef FBSessionLoginType enum
@abstract
Used as the type of the loginType property in order to specify what underlying technology was used to
login the user.
@discussion
The FBSession object is an abstraction over five distinct mechanisms. This enum allows an application
to test for the mechanism used by a particular instance of FBSession. Usually the mechanism used for a
given login does not matter, however for certain capabilities, the type of login can impact the behavior
of other Facebook functionality.
*/
typedef enum {
/*! A login type has not yet been established */
FBSessionLoginTypeNone = 0,
/*! A system integrated account was used to log the user into the application */
FBSessionLoginTypeSystemAccount = 1,
/*! The Facebook native application was used to log the user into the application */
FBSessionLoginTypeFacebookApplication = 2,
/*! Safari was used to log the user into the application */
FBSessionLoginTypeFacebookViaSafari = 3,
/*! A web view was used to log the user into the application */
FBSessionLoginTypeWebView = 4,
/*! A test user was used to create an open session */
FBSessionLoginTypeTestUser = 5,
} FBSessionLoginType;
/*!
@typedef
@abstract Block type used to define blocks called by <FBSession> for state updates
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
Requesting additional permissions inside this handler (such as by calling
`requestNewPublishPermissions`) should be avoided because it is a poor user
experience and its behavior may vary depending on the login type. You should
request the permissions closer to the operation that requires it (e.g., when
the user performs some action).
*/
typedef void (^FBSessionStateHandler)(FBSession *session,
FBSessionState status,
NSError *error);
/*!
@typedef
@abstract Block type used to define blocks called by <[FBSession requestNewReadPermissions:completionHandler:]>
and <[FBSession requestNewPublishPermissions:defaultAudience:completionHandler:]>.
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
Requesting additional permissions inside this handler (such as by calling
`requestNewPublishPermissions`) should be avoided because it is a poor user
experience and its behavior may vary depending on the login type. You should
request the permissions closer to the operation that requires it (e.g., when
the user performs some action).
*/
typedef void (^FBSessionRequestPermissionResultHandler)(FBSession *session,
NSError *error);
/*!
@typedef
@abstract Block type used to define blocks called by <[FBSession reauthorizeWithPermissions]>.
@discussion You should use the preferred FBSessionRequestPermissionHandler typedef rather than
this synonym, which has been deprecated.
*/
typedef FBSessionRequestPermissionResultHandler FBSessionReauthorizeResultHandler __attribute__((deprecated));
/*!
@typedef
@abstract Block type used to define blocks called for system credential renewals.
@discussion
*/
typedef void (^FBSessionRenewSystemCredentialsHandler)(ACAccountCredentialRenewResult result, NSError *error) ;
/*!
@class FBSession
@abstract
The `FBSession` object is used to authenticate a user and manage the user's session. After
initializing a `FBSession` object the Facebook App ID and desired permissions are stored.
Opening the session will initiate the authentication flow after which a valid user session
should be available and subsequently cached. Closing the session can optionally clear the
cache.
If an <FBRequest> request requires user authorization then an `FBSession` object should be used.
@discussion
Instances of the `FBSession` class provide notification of state changes in the following ways:
1. Callers of certain `FBSession` methods may provide a block that will be called
back in the course of state transitions for the session (e.g. login or session closed).
2. The object supports Key-Value Observing (KVO) for property changes.
*/
@interface FBSession : NSObject
/*!
@methodgroup Creating a session
*/
/*!
@method
@abstract
Returns a newly initialized Facebook session with default values for the parameters
to <initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:>.
*/
- (id)init;
/*!
@method
@abstract
Returns a newly initialized Facebook session with the specified permissions and other
default values for parameters to <initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:>.
@param permissions An array of strings representing the permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no
longer inferred, (subject to an active migration.) The default is nil.
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
or publish permissions only; not both. The permissions passed here should reflect this requirement.
*/
- (id)initWithPermissions:(NSArray*)permissions;
/*!
@method
@abstract
Following are the descriptions of the arguments along with their
defaults when ommitted.
@param permissions An array of strings representing the permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer inferred, (subject to an active migration.) The default is nil.
@param appID The Facebook App ID for the session. If nil is passed in the default App ID will be obtained from a call to <[FBSession defaultAppID]>. The default is nil.
@param urlSchemeSuffix The URL Scheme Suffix to be used in scenarious where multiple iOS apps use one Facebook App ID. A value of nil indicates that this information should be pulled from [FBSettings defaultUrlSchemeSuffix]. The default is nil.
@param tokenCachingStrategy Specifies a key name to use for cached token information in NSUserDefaults, nil
indicates a default value of @"FBAccessTokenInformationKey".
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
or publish permissions only; not both. The permissions passed here should reflect this requirement.
*/
- (id)initWithAppID:(NSString*)appID
permissions:(NSArray*)permissions
urlSchemeSuffix:(NSString*)urlSchemeSuffix
tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy;
/*!
@method
@abstract
Following are the descriptions of the arguments along with their
defaults when ommitted.
@param permissions An array of strings representing the permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer inferred, (subject to an active migration.) The default is nil.
@param defaultAudience Most applications use FBSessionDefaultAudienceNone here, only specifying an audience when using reauthorize to request publish permissions.
@param appID The Facebook App ID for the session. If nil is passed in the default App ID will be obtained from a call to <[FBSession defaultAppID]>. The default is nil.
@param urlSchemeSuffix The URL Scheme Suffix to be used in scenarious where multiple iOS apps use one Facebook App ID. A value of nil indicates that this information should be pulled from [FBSettings defaultUrlSchemeSuffix]. The default is nil.
@param tokenCachingStrategy Specifies a key name to use for cached token information in NSUserDefaults, nil
indicates a default value of @"FBAccessTokenInformationKey".
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
or publish permissions only; not both. The permissions passed here should reflect this requirement. If publish permissions
are used, then the audience must also be specified.
*/
- (id)initWithAppID:(NSString*)appID
permissions:(NSArray*)permissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
urlSchemeSuffix:(NSString*)urlSchemeSuffix
tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy;
// instance readonly properties
/*! @abstract Indicates whether the session is open and ready for use. */
@property (readonly) BOOL isOpen;
/*! @abstract Detailed session state */
@property (readonly) FBSessionState state;
/*! @abstract Identifies the Facebook app which the session object represents. */
@property (readonly, copy) NSString *appID;
/*! @abstract Identifies the URL Scheme Suffix used by the session. This is used when multiple iOS apps share a single Facebook app ID. */
@property (readonly, copy) NSString *urlSchemeSuffix;
/*! @abstract The access token for the session object.
@discussion Deprecated. Use the `accessTokenData` property. */
@property(readonly, copy) NSString *accessToken
__attribute__((deprecated));
/*! @abstract The expiration date of the access token for the session object.
@discussion Deprecated. Use the `accessTokenData` property. */
@property(readonly, copy) NSDate *expirationDate
__attribute__((deprecated));
/*! @abstract The permissions granted to the access token during the authentication flow. */
@property (readonly, copy) NSArray *permissions;
/*! @abstract Specifies the login type used to authenticate the user.
@discussion Deprecated. Use the `accessTokenData` property. */
@property(readonly) FBSessionLoginType loginType
__attribute__((deprecated));
/*! @abstract Gets the FBAccessTokenData for the session */
@property (readonly, copy) FBAccessTokenData *accessTokenData;
/*!
@methodgroup Instance methods
*/
/*!
@method
@abstract Opens a session for the Facebook.
@discussion
A session may not be used with <FBRequest> and other classes in the SDK until it is open. If, prior
to calling open, the session is in the <FBSessionStateCreatedTokenLoaded> state, then no UX occurs, and
the session becomes available for use. If the session is in the <FBSessionStateCreated> state, prior
to calling open, then a call to open causes login UX to occur, either via the Facebook application
or via mobile Safari.
Open may be called at most once and must be called after the `FBSession` is initialized. Open must
be called before the session is closed. Calling an open method at an invalid time will result in
an exception. The open session methods may be passed a block that will be called back when the session
state changes. The block will be released when the session is closed.
@param handler A block to call with the state changes. The default is nil.
*/
- (void)openWithCompletionHandler:(FBSessionStateHandler)handler;
/*!
@method
@abstract Logs a user on to Facebook.
@discussion
A session may not be used with <FBRequest> and other classes in the SDK until it is open. If, prior
to calling open, the session is in the <FBSessionStateCreatedTokenLoaded> state, then no UX occurs, and
the session becomes available for use. If the session is in the <FBSessionStateCreated> state, prior
to calling open, then a call to open causes login UX to occur, either via the Facebook application
or via mobile Safari.
The method may be called at most once and must be called after the `FBSession` is initialized. It must
be called before the session is closed. Calling the method at an invalid time will result in
an exception. The open session methods may be passed a block that will be called back when the session
state changes. The block will be released when the session is closed.
@param behavior Controls whether to allow, force, or prohibit Facebook Login or Inline Facebook Login. The default
is to allow Facebook Login, with fallback to Inline Facebook Login.
@param handler A block to call with session state changes. The default is nil.
*/
- (void)openWithBehavior:(FBSessionLoginBehavior)behavior
completionHandler:(FBSessionStateHandler)handler;
/*!
@method
@abstract Imports an existing access token and opens the session with it.
@discussion
The method attempts to open the session using an existing access token. No UX will occur. If
successful, the session with be in an Open state and the method will return YES; otherwise, NO.
The method may be called at most once and must be called after the `FBSession` is initialized (see below).
It must be called before the session is closed. Calling the method at an invalid time will result in
an exception. The open session methods may be passed a block that will be called back when the session
state changes. The block will be released when the session is closed.
The initialized session must not have already been initialized from a cache (for example, you could use
the `[FBSessionTokenCachingStrategy nullCacheInstance]` instance).
@param accessTokenData The token data. See `FBAccessTokenData` for construction methods.
@param handler A block to call with session state changes. The default is nil.
*/
- (BOOL)openFromAccessTokenData:(FBAccessTokenData *)accessTokenData completionHandler:(FBSessionStateHandler) handler;
/*!
@abstract
Closes the local in-memory session object, but does not clear the persisted token cache.
*/
- (void)close;
/*!
@abstract
Closes the in-memory session, and clears any persisted cache related to the session.
*/
- (void)closeAndClearTokenInformation;
/*!
@abstract
Reauthorizes the session, with additional permissions.
@param permissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions. The default is nil.
@param behavior Controls whether to allow, force, or prohibit Facebook Login. The default
is to allow Facebook Login and fall back to Inline Facebook Login if needed.
@param handler A block to call with session state changes. The default is nil.
@discussion Methods and properties that specify permissions without a read or publish
qualification are deprecated; use of a read-qualified or publish-qualified alternative is preferred
(e.g. reauthorizeWithReadPermissions or reauthorizeWithPublishPermissions)
*/
- (void)reauthorizeWithPermissions:(NSArray*)permissions
behavior:(FBSessionLoginBehavior)behavior
completionHandler:(FBSessionReauthorizeResultHandler)handler
__attribute__((deprecated));
/*!
@abstract
Reauthorizes the session, with additional permissions.
@param readPermissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions.
@param handler A block to call with session state changes. The default is nil.
@discussion This method is a deprecated alias of <[FBSession requestNewReadPermissions:completionHandler:]>. Consider
using <[FBSession requestNewReadPermissions:completionHandler:]>, which is preferred for readability.
*/
- (void)reauthorizeWithReadPermissions:(NSArray*)readPermissions
completionHandler:(FBSessionReauthorizeResultHandler)handler
__attribute__((deprecated));
/*!
@abstract
Reauthorizes the session, with additional permissions.
@param writePermissions An array of strings representing the permissions to request during the
authentication flow.
@param defaultAudience Specifies the audience for posts.
@param handler A block to call with session state changes. The default is nil.
@discussion This method is a deprecated alias of <[FBSession requestNewPublishPermissions:defaultAudience:completionHandler:]>.
Consider using <[FBSession requestNewPublishPermissions:defaultAudience:completionHandler:]>, which is preferred for readability.
*/
- (void)reauthorizeWithPublishPermissions:(NSArray*)writePermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
completionHandler:(FBSessionReauthorizeResultHandler)handler
__attribute__((deprecated));
/*!
@abstract
Requests new or additional read permissions for the session.
@param readPermissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions.
@param handler A block to call with session state changes. The default is nil.
@discussion The handler, if non-nil, is called once the operation has completed or failed. This is in contrast to the
state completion handler used in <[FBSession openWithCompletionHandler:]> (and other `open*` methods) which is called
for each state-change for the session.
*/
- (void)requestNewReadPermissions:(NSArray*)readPermissions
completionHandler:(FBSessionRequestPermissionResultHandler)handler;
/*!
@abstract
Requests new or additional write permissions for the session.
@param writePermissions An array of strings representing the permissions to request during the
authentication flow.
@param defaultAudience Specifies the audience for posts.
@param handler A block to call with session state changes. The default is nil.
@discussion The handler, if non-nil, is called once the operation has completed or failed. This is in contrast to the
state completion handler used in <[FBSession openWithCompletionHandler:]> (and other `open*` methods) which is called
for each state-change for the session.
*/
- (void)requestNewPublishPermissions:(NSArray*)writePermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
completionHandler:(FBSessionRequestPermissionResultHandler)handler;
/*!
@abstract
A helper method that is used to provide an implementation for
[UIApplicationDelegate application:openURL:sourceApplication:annotation:]. It should be invoked during
the Facebook Login flow and will update the session information based on the incoming URL.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
*/
- (BOOL)handleOpenURL:(NSURL*)url;
/*!
@abstract
A helper method that is used to provide an implementation for
[UIApplicationDelegate applicationDidBecomeActive:] to properly resolve session state for
the Facebook Login flow, specifically to support app-switch login.
*/
- (void)handleDidBecomeActive;
/*!
@abstract
Assign the block to be invoked for session state changes.
@discussion
This will overwrite any state change handler that was already assigned. Typically,
you should only use this setter if you were unable to assign a state change handler explicitly.
One example of this is if you are not opening the session (e.g., using the `open*`)
but still want to assign a `FBSessionStateHandler` block. This can happen when the SDK
opens a session from an app link.
*/
- (void)setStateChangeHandler:(FBSessionStateHandler)stateChangeHandler;
/*!
@methodgroup Class methods
*/
/*!
@abstract
This is the simplest method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
Note, if there is not a cached token available, this method will present UI to the user in order to
open the session via explicit login by the user.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be disirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@discussion
Returns YES if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
*/
+ (BOOL)openActiveSessionWithAllowLoginUI:(BOOL)allowLoginUI;
/*!
@abstract
This is a simple method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
@param permissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions. A nil value specifies
default permissions.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be desirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@param handler Many applications will benefit from notification when a session becomes invalid
or undergoes other state transitions. If a block is provided, the FBSession
object will call the block each time the session changes state.
@discussion
Returns true if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
It is required that initial permissions requests represent read-only permissions only. If publish
permissions are needed, you may use reauthorizeWithPermissions to specify additional permissions as
well as an audience. Use of this method will result in a legacy fast-app-switch Facebook Login due to
the requirement to separate read and publish permissions for newer applications. Methods and properties
that specify permissions without a read or publish qualification are deprecated; use of a read-qualified
or publish-qualified alternative is preferred.
*/
+ (BOOL)openActiveSessionWithPermissions:(NSArray*)permissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler
__attribute__((deprecated));
/*!
@abstract
This is a simple method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
@param readPermissions An array of strings representing the read permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer
inferred, (subject to an active migration.) It is not allowed to pass publish permissions to this method.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be desirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@param handler Many applications will benefit from notification when a session becomes invalid
or undergoes other state transitions. If a block is provided, the FBSession
object will call the block each time the session changes state.
@discussion
Returns true if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
*/
+ (BOOL)openActiveSessionWithReadPermissions:(NSArray*)readPermissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
/*!
@abstract
This is a simple method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
@param publishPermissions An array of strings representing the publish permissions to request during the
authentication flow.
@param defaultAudience Anytime an app publishes on behalf of a user, the post must have an audience (e.g. me, my friends, etc.)
The default audience is used to notify the user of the cieling that the user agrees to grant to the app for the provided permissions.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be desirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@param handler Many applications will benefit from notification when a session becomes invalid
or undergoes other state transitions. If a block is provided, the FBSession
object will call the block each time the session changes state.
@discussion
Returns true if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
*/
+ (BOOL)openActiveSessionWithPublishPermissions:(NSArray*)publishPermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
/*!
@abstract
An application may get or set the current active session. Certain high-level components in the SDK
will use the activeSession to set default session (e.g. `FBLoginView`, `FBFriendPickerViewController`)
@discussion
If sessionOpen* is called, the resulting `FBSession` object also becomes the activeSession. If another
session was active at the time, it is closed automatically. If activeSession is called when no session
is active, a session object is instatiated and returned; in this case open must be called on the session
in order for it to be useable for communication with Facebook.
*/
+ (FBSession*)activeSession;
/*!
@abstract
An application may get or set the current active session. Certain high-level components in the SDK
will use the activeSession to set default session (e.g. `FBLoginView`, `FBFriendPickerViewController`)
@param session The FBSession object to become the active session
@discussion
If an application prefers the flexibilility of directly instantiating a session object, an active
session can be set directly.
*/
+ (FBSession*)setActiveSession:(FBSession*)session;
/*!
@method
@abstract Set the default Facebook App ID to use for sessions. The app ID may be
overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings setDefaultAppID].
@param appID The default Facebook App ID to use for <FBSession> methods.
*/
+ (void)setDefaultAppID:(NSString*)appID __attribute__((deprecated));
/*!
@method
@abstract Get the default Facebook App ID to use for sessions. If not explicitly
set, the default will be read from the application's plist. The app ID may be
overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings defaultAppID].
*/
+ (NSString*)defaultAppID __attribute__((deprecated));
/*!
@method
@abstract Set the default url scheme suffix to use for sessions. The url
scheme suffix may be overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings setDefaultUrlSchemeSuffix].
@param urlSchemeSuffix The default url scheme suffix to use for <FBSession> methods.
*/
+ (void)setDefaultUrlSchemeSuffix:(NSString*)urlSchemeSuffix __attribute__((deprecated));
/*!
@method
@abstract Get the default url scheme suffix used for sessions. If not
explicitly set, the default will be read from the application's plist. The
url scheme suffix may be overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings defaultUrlSchemeSuffix].
*/
+ (NSString*)defaultUrlSchemeSuffix __attribute__((deprecated));
/*!
@method
@abstract Issues an asychronous renewCredentialsForAccount call to the device Facebook account store.
@param handler The completion handler to call when the renewal is completed. The handler will be
invoked on the main thread.
@discussion This can be used to explicitly renew account credentials on iOS 6 devices and is provided
as a convenience wrapper around `[ACAccountStore renewCredentialsForAccount:completion]`. Note the
method will not issue the renewal call if the the Facebook account has not been set on the device, or
if access had not been granted to the account (though the handler wil receive an error).
This is safe to call (and will surface an error to the handler) on versions of iOS before 6 or if the user
logged in via Safari or Facebook SSO.
*/
+ (void)renewSystemCredentials:(FBSessionRenewSystemCredentialsHandler)handler;
@end

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2010-present 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 "FBSessionTokenCachingStrategy.h"
// FBSessionManualTokenCachingStrategy
//
// Summary:
// Internal use only, this class enables migration logic for the Facebook class, by providing
// a means to directly provide the access token to a FBSession object
//
@interface FBSessionManualTokenCachingStrategy : FBSessionTokenCachingStrategy
// set the properties before instantiating the FBSession object in order to seed a token
@property (readwrite, copy) NSString* accessToken;
@property (readwrite, copy) NSDate* expirationDate;
@end

View File

@@ -0,0 +1,160 @@
/*
* Copyright 2010-present 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 "FBAccessTokenData.h"
/*!
@class
@abstract
The `FBSessionTokenCachingStrategy` class is responsible for persisting and retrieving cached data related to
an <FBSession> object, including the user's Facebook access token.
@discussion
`FBSessionTokenCachingStrategy` is designed to be instantiated directly or used as a base class. Usually default
token caching behavior is sufficient, and you do not need to interface directly with `FBSessionTokenCachingStrategy` objects.
However, if you need to control where or how `FBSession` information is cached, then you may take one of two approaches.
The first and simplest approach is to instantiate an instance of `FBSessionTokenCachingStrategy`, and then pass
the instance to `FBSession` class' `init` method. This enables your application to control the key name used in
`NSUserDefaults` to store session information. You may consider this approach if you plan to cache session information
for multiple users.
The second and more advanced approached is to derive a custom class from `FBSessionTokenCachingStrategy`, which will
be responsible for caching behavior of your application. This approach is useful if you need to change where the
information is cached, for example if you prefer to use the filesystem or make a network connection to fetch and
persist cached tokens. Inheritors should override the cacheTokenInformation, fetchTokenInformation, and clearToken methods.
Doing this enables your application to implement any token caching scheme, including no caching at all (see
`[FBSessionTokenCachingStrategy* nullCacheInstance ]`.
Direct use of `FBSessionTokenCachingStrategy`is an advanced technique. Most applications use <FBSession> objects without
passing an `FBSessionTokenCachingStrategy`, which yields default caching to `NSUserDefaults`.
*/
@interface FBSessionTokenCachingStrategy : NSObject
/*!
@abstract Initializes and returns an instance
*/
- (id)init;
/*!
@abstract
Initializes and returns an instance
@param tokenInformationKeyName Specifies a key name to use for cached token information in NSUserDefaults, nil
indicates a default value of @"FBAccessTokenInformationKey"
*/
- (id)initWithUserDefaultTokenInformationKeyName:(NSString*)tokenInformationKeyName;
/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order to cache token information.
@param tokenInformation Dictionary containing token information to be cached by the method
@discussion You should favor overriding this instead of `cacheFBAccessTokenData` only if you intend
to cache additional data not captured by the FBAccessTokenData type.
*/
- (void)cacheTokenInformation:(NSDictionary*)tokenInformation;
/*!
@abstract Cache the supplied token.
@param accessToken The token instance.
@discussion This essentially wraps a call to `cacheTokenInformation` so you should
override this when providing a custom token caching strategy.
*/
- (void)cacheFBAccessTokenData:(FBAccessTokenData *)accessToken;
/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order to fetch cached token information
@discussion
An overriding implementation should only return a token if it
can also return an expiration date, otherwise return nil.
You should favor overriding this instead of `fetchFBAccessTokenData` only if you intend
to cache additional data not captured by the FBAccessTokenData type.
*/
- (NSDictionary*)fetchTokenInformation;
/*!
@abstract
Fetches the cached token instance.
@discussion
This essentially wraps a call to `fetchTokenInformation` so you should
override this when providing a custom token caching strategy.
In order for an `FBSession` instance to be able to use a cached token,
the token must be not be expired (see `+isValidTokenInformation:`) and
must also contain all permissions in the initialized session instance.
*/
- (FBAccessTokenData *)fetchFBAccessTokenData;
/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order delete any cached information for the current token
*/
- (void)clearToken;
/*!
@abstract
Helper function called by the SDK as well as apps, in order to fetch the default strategy instance.
*/
+ (FBSessionTokenCachingStrategy*)defaultInstance;
/*!
@abstract
Helper function to return a FBSessionTokenCachingStrategy instance that does not perform any caching.
*/
+ (FBSessionTokenCachingStrategy*)nullCacheInstance;
/*!
@abstract
Helper function called by the SDK as well as application code, used to determine whether a given dictionary
contains the minimum token information usable by the <FBSession>.
@param tokenInformation Dictionary containing token information to be validated
*/
+ (BOOL)isValidTokenInformation:(NSDictionary*)tokenInformation;
@end
// The key to use with token information dictionaries to get and set the token value
extern NSString *const FBTokenInformationTokenKey;
// The to use with token information dictionaries to get and set the expiration date
extern NSString *const FBTokenInformationExpirationDateKey;
// The to use with token information dictionaries to get and set the refresh date
extern NSString *const FBTokenInformationRefreshDateKey;
// The key to use with token information dictionaries to get the related user's fbid
extern NSString *const FBTokenInformationUserFBIDKey;
// The key to use with token information dictionaries to determine whether the token was fetched via Facebook Login
extern NSString *const FBTokenInformationIsFacebookLoginKey;
// The key to use with token information dictionaries to determine whether the token was fetched via the OS
extern NSString *const FBTokenInformationLoginTypeLoginKey;
// The key to use with token information dictionaries to get the latest known permissions
extern NSString *const FBTokenInformationPermissionsKey;
// The key to use with token information dictionaries to get the date the permissions were last refreshed.
extern NSString *const FBTokenInformationPermissionsRefreshDateKey;

View File

@@ -0,0 +1,327 @@
/*
* Copyright 2010-present 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 <CoreGraphics/CGBase.h>
/*
* Constants defining logging behavior. Use with <[FBSettings setLoggingBehavior]>.
*/
/*! Log requests from FBRequest* classes */
extern NSString *const FBLoggingBehaviorFBRequests;
/*! Log requests from FBURLConnection* classes */
extern NSString *const FBLoggingBehaviorFBURLConnections;
/*! Include access token in logging. */
extern NSString *const FBLoggingBehaviorAccessTokens;
/*! Log session state transitions. */
extern NSString *const FBLoggingBehaviorSessionStateTransitions;
/*! Log performance characteristics */
extern NSString *const FBLoggingBehaviorPerformanceCharacteristics;
/*! Log FBAppEvents interactions */
extern NSString *const FBLoggingBehaviorAppEvents;
/*! Log Informational occurrences */
extern NSString *const FBLoggingBehaviorInformational;
/*! Log errors likely to be preventable by the developer. This is in the default set of enabled logging behaviors. */
extern NSString *const FBLoggingBehaviorDeveloperErrors;
@class FBGraphObject;
/*!
@typedef
@abstract Block type used to get install data that is returned by server when publishInstall is called
@discussion
*/
typedef void (^FBInstallResponseDataHandler)(FBGraphObject *response, NSError *error);
/*!
@typedef
@abstract A list of beta features that can be enabled for the SDK. Beta features are for evaluation only,
and are therefore only enabled for DEBUG builds. Beta features should not be enabled
in release builds.
*/
typedef enum : NSUInteger {
FBBetaFeaturesNone = 0,
#if defined(DEBUG) || defined(FB_BUILD_ONLY)
FBBetaFeaturesShareDialog = 1 << 0,
FBBetaFeaturesOpenGraphShareDialog = 1 << 1,
#endif
} FBBetaFeatures;
/*!
@typedef
@abstract Indicates if this app should be restricted
*/
typedef NS_ENUM(NSUInteger, FBRestrictedTreatment) {
/*! The default treatment indicating the app is not restricted. */
FBRestrictedTreatmentNO = 0,
/*! Indicates the app is restricted. */
FBRestrictedTreatmentYES = 1
};
@interface FBSettings : NSObject
/*!
@method
@abstract Retrieve the current iOS SDK version.
*/
+ (NSString *)sdkVersion;
/*!
@method
@abstract Retrieve the current Facebook SDK logging behavior.
*/
+ (NSSet *)loggingBehavior;
/*!
@method
@abstract Set the current Facebook SDK logging behavior. This should consist of strings defined as
constants with FBLogBehavior*, and can be constructed with, e.g., [NSSet initWithObjects:].
@param loggingBehavior A set of strings indicating what information should be logged. If nil is provided, the logging
behavior is reset to the default set of enabled behaviors. Set in an empty set in order to disable all logging.
*/
+ (void)setLoggingBehavior:(NSSet *)loggingBehavior;
/*! @abstract deprecated method */
+ (BOOL)shouldAutoPublishInstall __attribute__ ((deprecated));
/*! @abstract deprecated method */
+ (void)setShouldAutoPublishInstall:(BOOL)autoPublishInstall __attribute__ ((deprecated));
/*!
@method
@abstract This method has been replaced by [FBAppEvents activateApp] */
+ (void)publishInstall:(NSString *)appID __attribute__ ((deprecated("use [FBAppEvents activateApp] instead")));
/*!
@method
@abstract Manually publish an attributed install to the Facebook graph, and return the server response back in
the supplied handler. Calling this method will implicitly turn off auto-publish. This method acquires the
current attribution id from the facebook application, queries the graph API to determine if the application
has install attribution enabled, publishes the id, and records success to avoid reporting more than once.
@param appID A specific appID to publish an install for. If nil, uses [FBSession defaultAppID].
@param handler A block to call with the server's response.
*/
+ (void)publishInstall:(NSString *)appID
withHandler:(FBInstallResponseDataHandler)handler __attribute__ ((deprecated));
/*!
@method
@abstract
Gets the application version to the provided string. `FBAppEvents`, for instance, attaches the app version to
events that it logs, which are then available in App Insights.
*/
+ (NSString *)appVersion;
/*!
@method
@abstract
Sets the application version to the provided string. `FBAppEvents`, for instance, attaches the app version to
events that it logs, which are then available in App Insights.
@param appVersion The version identifier of the iOS app.
*/
+ (void)setAppVersion:(NSString *)appVersion;
/*!
@method
@abstract Retrieve the Client Token that has been set via [FBSettings setClientToken]
*/
+ (NSString *)clientToken;
/*!
@method
@abstract Sets the Client Token for the Facebook App. This is needed for certain API calls when made anonymously,
without a user-based Session.
@param clientToken The Facebook App's "client token", which, for a given appid can be found in the Security
section of the Advanced tab of the Facebook App settings found at <https://developers.facebook.com/apps/[your-app-id]>
*/
+ (void)setClientToken:(NSString *)clientToken;
/*!
@method
@abstract Set the default Facebook Display Name to be used by the SDK. This should match
the Display Name that has been set for the app with the corresponding Facebook App ID, in
the Facebook App Dashboard
@param displayName The default Facebook Display Name to be used by the SDK.
*/
+ (void)setDefaultDisplayName:(NSString *)displayName;
/*!
@method
@abstract Get the default Facebook Display Name used by the SDK. If not explicitly
set, the default will be read from the application's plist.
*/
+ (NSString *)defaultDisplayName;
/*!
@method
@abstract Set the default Facebook App ID to use for sessions. The SDK allows the appID
to be overridden per instance in certain cases (e.g. per instance of FBSession)
@param appID The default Facebook App ID to be used by the SDK.
*/
+ (void)setDefaultAppID:(NSString*)appID;
/*!
@method
@abstract Get the default Facebook App ID used by the SDK. If not explicitly
set, the default will be read from the application's plist. The SDK allows the appID
to be overridden per instance in certain cases (e.g. per instance of FBSession)
*/
+ (NSString*)defaultAppID;
/*!
@method
@abstract Set the default url scheme suffix used by the SDK.
@param urlSchemeSuffix The default url scheme suffix to be used by the SDK.
*/
+ (void)setDefaultUrlSchemeSuffix:(NSString*)urlSchemeSuffix;
/*!
@method
@abstract Get the default url scheme suffix used for sessions. If not
explicitly set, the default will be read from the application's plist value for 'FacebookUrlSchemeSuffix'.
*/
+ (NSString*)defaultUrlSchemeSuffix;
/*!
@method
@abstract Set the bundle name from the SDK will try and load overrides of images and text
@param bundleName The name of the bundle (MyFBBundle).
*/
+ (void)setResourceBundleName:(NSString*)bundleName;
/*!
@method
@abstract Get the name of the bundle to override the SDK images and text
*/
+ (NSString*)resourceBundleName;
/*!
@method
@abstract Set the subpart of the facebook domain (e.g. @"beta") so that requests will be sent to graph.beta.facebook.com
@param facebookDomainPart The domain part to be inserted into facebook.com
*/
+ (void)setFacebookDomainPart:(NSString*)facebookDomainPart;
/*!
@method
@abstract Get the Facebook domain part
*/
+ (NSString*)facebookDomainPart;
/*!
@method
@abstract Enables the specified beta features. Beta features are for evaluation only,
and are therefore only enabled for debug builds. Beta features should not be enabled
in release builds.
@param betaFeatures The beta features to enable (expects a bitwise OR of FBBetaFeatures)
*/
+ (void)enableBetaFeatures:(NSUInteger)betaFeatures;
/*!
@method
@abstract Enables a beta feature. Beta features are for evaluation only,
and are therefore only enabled for debug builds. Beta features should not be enabled
in release builds.
@param betaFeature The beta feature to enable.
*/
+ (void)enableBetaFeature:(FBBetaFeatures)betaFeature;
/*!
@method
@abstract Disables a beta feature.
@param betaFeature The beta feature to disable.
*/
+ (void)disableBetaFeature:(FBBetaFeatures)betaFeature;
/*!
@method
@abstract Determines whether a beta feature is enabled or not.
@param betaFeature The beta feature to check.
@return YES if the beta feature is enabled, NO if not.
*/
+ (BOOL)isBetaFeatureEnabled:(FBBetaFeatures)betaFeature;
/*!
@method
@abstract
Gets whether data such as that generated through FBAppEvents and sent to Facebook should be restricted from being used for other than analytics and conversions. Defaults to NO. This value is stored on the device and persists across app launches.
*/
+ (BOOL)limitEventAndDataUsage;
/*!
@method
@abstract
Sets whether data such as that generated through FBAppEvents and sent to Facebook should be restricted from being used for other than analytics and conversions. Defaults to NO. This value is stored on the device and persists across app launches.
@param limitEventAndDataUsage The desired value.
*/
+ (void)setLimitEventAndDataUsage:(BOOL)limitEventAndDataUsage;
@end

View File

@@ -0,0 +1,67 @@
/*
* Copyright 2010-present 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 "FBDialogsParams.h"
/*!
@class FBShareDialogParams
@abstract
This object is used to encapsulate state for parameters to a share dialog that
opens in the Facebook app.
*/
@interface FBShareDialogParams : FBDialogsParams
/*! @abstract The URL link to be attached to the post. Only "http" or "https"
schemes are supported. */
@property (nonatomic, copy) NSURL *link;
/*! @abstract The name, or title associated with the link. Is only used if the
link is non-nil. */
@property (nonatomic, copy) NSString *name;
/*! @abstract The caption to be used with the link. Is only used if the link is
non-nil. */
@property (nonatomic, copy) NSString *caption;
/*! @abstract The description associated with the link. Is only used if the
link is non-nil. */
@property (nonatomic, copy) NSString *description;
/*! @abstract The link to a thumbnail to associate with the post. Is only used
if the link is non-nil. Only "http" or "https" schemes are supported.*/
@property (nonatomic, copy) NSURL *picture;
/*! @abstract An array of NSStrings or FBGraphUsers to tag in the post.
If using NSStrings, the values must represent the IDs of the users to tag. */
@property (nonatomic, copy) NSArray *friends;
/*! @abstract An NSString or FBGraphPlace to tag in the status update. If
NSString, the value must be the ID of the place to tag. */
@property (nonatomic, copy) id place;
/*! @abstract A text reference for the category of the post, used on Facebook
Insights. */
@property (nonatomic, copy) NSString *ref;
/*! @abstract If YES, treats any data failures (e.g. failures when getting
data for IDs passed through "friends" or "place") as a fatal error, and will not
continue with the status update. */
@property (nonatomic, assign) BOOL dataFailuresFatal;
@end

View File

@@ -0,0 +1,138 @@
/*
* Copyright 2010-present 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 "FBSession.h"
#if defined (DEBUG)
#define SAFE_TO_USE_FBTESTSESSION
#endif
#if !defined(SAFE_TO_USE_FBTESTSESSION)
#pragma message ("warning: using FBTestSession, which is designed for unit-testing uses only, in non-DEBUG code -- ensure this is what you really want")
#endif
/*!
Consider using this tag to pass to sessionWithSharedUserWithPermissions:uniqueUserTag: when
you need a second unique test user in a test case. Using the same tag each time reduces
the proliferation of test users.
*/
extern NSString *kSecondTestUserTag;
/*!
Consider using this tag to pass to sessionWithSharedUserWithPermissions:uniqueUserTag: when
you need a third unique test user in a test case. Using the same tag each time reduces
the proliferation of test users.
*/
extern NSString *kThirdTestUserTag;
/*!
@class FBTestSession
@abstract
Implements an FBSession subclass that knows about test users for a particular
application. This should never be used from a real application, but may be useful
for writing unit tests, etc.
@discussion
Facebook allows developers to create test accounts for testing their applications'
Facebook integration (see https://developers.facebook.com/docs/test_users/). This class
simplifies use of these accounts for writing unit tests. It is not designed for use in
production application code.
The main use case for this class is using sessionForUnitTestingWithPermissions:mode:
to create a session for a test user. Two modes are supported. In "shared" mode, an attempt
is made to find an existing test user that has the required permissions and, if it is not
currently in use by another FBTestSession, just use that user. If no such user is available,
a new one is created with the required permissions. In "private" mode, designed for
scenarios which require a new user in a known clean state, a new test user will always be
created, and it will be automatically deleted when the FBTestSession is closed.
Note that the shared test user functionality depends on a naming convention for the test users.
It is important that any testing of functionality which will mutate the permissions for a
test user NOT use a shared test user, or this scheme will break down. If a shared test user
seems to be in an invalid state, it can be deleted manually via the Web interface at
https://developers.facebook.com/apps/APP_ID/permissions?role=test+users.
*/
@interface FBTestSession : FBSession
/// The app access token (composed of app ID and secret) to use for accessing test users.
@property (readonly, copy) NSString *appAccessToken;
/// The ID of the test user associated with this session.
@property (readonly, copy) NSString *testUserID;
/// The App ID of the test app as configured in the plist.
@property (readonly, copy) NSString *testAppID;
/// The App Secret of the test app as configured in the plist.
@property (readonly, copy) NSString *testAppSecret;
// Defaults to NO. If set to YES, reauthorize calls will fail with a nil token
// as if the user had cancelled it reauthorize.
@property (assign) BOOL disableReauthorize;
/*!
@abstract
Constructor helper to create a session for use in unit tests
@discussion
This method creates a session object which uses a shared test user with the right permissions,
creating one if necessary on open (but not deleting it on close, so it can be re-used in later
tests). Calling this method multiple times may return sessions with the same user. If this is not
desired, use the variant sessionWithSharedUserWithPermissions:uniqueUserTag:.
This method should not be used in application code -- but is useful for creating unit tests
that use the Facebook SDK.
@param permissions array of strings naming permissions to authorize; nil indicates
a common default set of permissions should be used for unit testing
*/
+ (id)sessionWithSharedUserWithPermissions:(NSArray*)permissions;
/*!
@abstract
Constructor helper to create a session for use in unit tests
@discussion
This method creates a session object which uses a shared test user with the right permissions,
creating one if necessary on open (but not deleting it on close, so it can be re-used in later
tests).
This method should not be used in application code -- but is useful for creating unit tests
that use the Facebook SDK.
@param permissions array of strings naming permissions to authorize; nil indicates
a common default set of permissions should be used for unit testing
@param uniqueUserTag a string which will be used to make this user unique among other
users with the same permissions. Useful for tests which require two or more users to interact
with each other, and which therefore must have sessions associated with different users. For
this case, consider using kSecondTestUserTag and kThirdTestUserTag so these users can be shared
with other, similar, tests.
*/
+ (id)sessionWithSharedUserWithPermissions:(NSArray*)permissions
uniqueUserTag:(NSString*)uniqueUserTag;
/*!
@abstract
Constructor helper to create a session for use in unit tests
@discussion
This method creates a session object which creates a test user on open, and destroys the user on
close; This method should not be used in application code -- but is useful for creating unit tests
that use the Facebook SDK.
@param permissions array of strings naming permissions to authorize; nil indicates
a common default set of permissions should be used for unit testing
*/
+ (id)sessionWithPrivateUserWithPermissions:(NSArray*)permissions;
@end

View File

@@ -0,0 +1,128 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
#import "FBSession.h"
#import "FBViewController.h"
/*!
@protocol
@abstract
The `FBUserSettingsDelegate` protocol defines the methods called by a <FBUserSettingsViewController>.
*/
@protocol FBUserSettingsDelegate <FBViewControllerDelegate>
@optional
/*!
@abstract
Called when the view controller will log the user out in response to a button press.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerWillLogUserOut:(id)sender;
/*!
@abstract
Called after the view controller logged the user out in response to a button press.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerDidLogUserOut:(id)sender;
/*!
@abstract
Called when the view controller will log the user in in response to a button press.
Note that logging in can fail for a number of reasons, so there is no guarantee that this
will be followed by a call to loginViewControllerDidLogUserIn:. Callers wanting more granular
notification of the session state changes can use KVO or the NSNotificationCenter to observe them.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerWillAttemptToLogUserIn:(id)sender;
/*!
@abstract
Called after the view controller successfully logged the user in in response to a button press.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerDidLogUserIn:(id)sender;
/*!
@abstract
Called if the view controller encounters an error while trying to log a user in.
@param sender The view controller sending the message.
@param error The error encountered.
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
*/
- (void)loginViewController:(id)sender receivedError:(NSError *)error;
@end
/*!
@class FBUserSettingsViewController
@abstract
The `FBUserSettingsViewController` class provides a user interface exposing a user's
Facebook-related settings. Currently, this is limited to whether they are logged in or out
of Facebook.
Because of the size of some graphics used in this view, its resources are packaged as a separate
bundle. In order to use `FBUserSettingsViewController`, drag the `FBUserSettingsViewResources.bundle`
from the SDK directory into your Xcode project.
*/
@interface FBUserSettingsViewController : FBViewController
/*!
@abstract
The permissions to request if the user logs in via this view.
*/
@property (nonatomic, copy) NSArray *permissions __attribute__((deprecated));
/*!
@abstract
The read permissions to request if the user logs in via this view.
@discussion
Note, that if read permissions are specified, then publish permissions should not be specified.
*/
@property (nonatomic, copy) NSArray *readPermissions;
/*!
@abstract
The publish permissions to request if the user logs in via this view.
@discussion
Note, that a defaultAudience value of FBSessionDefaultAudienceOnlyMe, FBSessionDefaultAudienceEveryone, or
FBSessionDefaultAudienceFriends should be set if publish permissions are specified. Additionally, when publish
permissions are specified, then read should not be specified.
*/
@property (nonatomic, copy) NSArray *publishPermissions;
/*!
@abstract
The default audience to use, if publish permissions are requested at login time.
*/
@property (nonatomic, assign) FBSessionDefaultAudience defaultAudience;
@end

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
@class FBViewController;
/*!
@typedef FBModalCompletionHandler
@abstract
A block that is passed to [FBViewController presentModallyInViewController:animated:handler:]
and called when the view controller is dismissed via either Done or Cancel.
@param sender The <FBViewController> that is being dismissed.
@param donePressed If YES, Done was pressed. If NO, Cancel was pressed.
*/
typedef void (^FBModalCompletionHandler)(FBViewController *sender, BOOL donePressed);
/*!
@protocol
@abstract
The `FBViewControllerDelegate` protocol defines the methods called when the Cancel or Done
buttons are pressed in a <FBViewController>.
*/
@protocol FBViewControllerDelegate <NSObject>
@optional
/*!
@abstract
Called when the Cancel button is pressed on a modally-presented <FBViewController>.
@param sender The view controller sending the message.
*/
- (void)facebookViewControllerCancelWasPressed:(id)sender;
/*!
@abstract
Called when the Done button is pressed on a modally-presented <FBViewController>.
@param sender The view controller sending the message.
*/
- (void)facebookViewControllerDoneWasPressed:(id)sender;
@end
/*!
@class FBViewController
@abstract
The `FBViewController` class is a base class encapsulating functionality common to several
other view controller classes. Specifically, it provides UI when a view controller is presented
modally, in the form of optional Cancel and Done buttons.
*/
@interface FBViewController : UIViewController
/*!
@abstract
The Cancel button to display when presented modally. If nil, no Cancel button is displayed.
If this button is provided, its target and action will be redirected to internal handlers, replacing
any previous target that may have been set.
*/
@property (nonatomic, retain) IBOutlet UIBarButtonItem *cancelButton;
/*!
@abstract
The Done button to display when presented modally. If nil, no Done button is displayed.
If this button is provided, its target and action will be redirected to internal handlers, replacing
any previous target that may have been set.
*/
@property (nonatomic, retain) IBOutlet UIBarButtonItem *doneButton;
/*!
@abstract
The delegate that will be called when Cancel or Done is pressed. Derived classes may specify
derived types for their delegates that provide additional functionality.
*/
@property (nonatomic, assign) IBOutlet id<FBViewControllerDelegate> delegate;
/*!
@abstract
The view into which derived classes should put their subviews. This view will be resized correctly
depending on whether or not a toolbar is displayed.
*/
@property (nonatomic, readonly, retain) UIView *canvasView;
/*!
@abstract
Provides a wrapper that presents the view controller modally and automatically dismisses it
when either the Done or Cancel button is pressed.
@param viewController The view controller that is presenting this view controller.
@param animated If YES, presenting and dismissing the view controller is animated.
@param handler The block called when the Done or Cancel button is pressed.
*/
- (void)presentModallyFromViewController:(UIViewController*)viewController
animated:(BOOL)animated
handler:(FBModalCompletionHandler)handler;
@end

View File

@@ -0,0 +1,234 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
@class FBFrictionlessRecipientCache;
@class FBSession;
@protocol FBWebDialogsDelegate;
/*!
@typedef FBWebDialogResult enum
@abstract
Passed to a handler to indicate the result of a dialog being displayed to the user.
*/
typedef enum {
/*! Indicates that the dialog action completed successfully. Note, that cancel operations represent completed dialog operations.
The url argument may be used to distinguish between success and user-cancelled cases */
FBWebDialogResultDialogCompleted,
/*! Indicates that the dialog operation was not completed. This occurs in cases such as the closure of the web-view using the X in the upper left corner. */
FBWebDialogResultDialogNotCompleted
} FBWebDialogResult;
/*!
@typedef
@abstract Defines a handler that will be called in response to the web dialog
being dismissed
*/
typedef void (^FBWebDialogHandler)(
FBWebDialogResult result,
NSURL *resultURL,
NSError *error);
/*!
@class FBWebDialogs
@abstract
Provides methods to display web based dialogs to the user.
*/
@interface FBWebDialogs : NSObject
/*!
@abstract
Presents a Facebook web dialog (https://developers.facebook.com/docs/reference/dialogs/ )
such as feed or apprequest.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present, or returns NO, if not.
@param dialog Represents the dialog or method name, such as @"feed"
@param parameters A dictionary of parameters to be passed to the dialog
@param handler An optional handler that will be called when the dialog is dismissed. Note,
that if the method returns NO, the handler is not called. May be nil.
*/
+ (void)presentDialogModallyWithSession:(FBSession *)session
dialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler;
/*!
@abstract
Presents a Facebook web dialog (https://developers.facebook.com/docs/reference/dialogs/ )
such as feed or apprequest.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present, or returns NO, if not.
@param dialog Represents the dialog or method name, such as @"feed"
@param parameters A dictionary of parameters to be passed to the dialog
@param handler An optional handler that will be called when the dialog is dismissed. Note,
that if the method returns NO, the handler is not called. May be nil.
@param delegate An optional delegate to allow for advanced processing of web based
dialogs. See 'FBWebDialogsDelegate' for more details.
*/
+ (void)presentDialogModallyWithSession:(FBSession *)session
dialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler
delegate:(id<FBWebDialogsDelegate>)delegate;
/*!
@abstract
Presents a Facebook apprequest dialog.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present.
@param message The required message for the dialog.
@param title An optional title for the dialog.
@param parameters A dictionary of additional parameters to be passed to the dialog. May be nil
@param handler An optional handler that will be called when the dialog is dismissed. May be nil.
*/
+ (void)presentRequestsDialogModallyWithSession:(FBSession *)session
message:(NSString *)message
title:(NSString *)title
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler;
/*!
@abstract
Presents a Facebook apprequest dialog.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present.
@param message The required message for the dialog.
@param title An optional title for the dialog.
@param parameters A dictionary of additional parameters to be passed to the dialog. May be nil
@param handler An optional handler that will be called when the dialog is dismissed. May be nil.
@param friendCache An optional cache object used to enable frictionless sharing for a known set of friends. The
cache instance should be preserved for the life of the session and reused for multiple calls to the present method.
As the users set of friends enabled for frictionless sharing changes, this method auto-updates the cache.
*/
+ (void)presentRequestsDialogModallyWithSession:(FBSession *)session
message:(NSString *)message
title:(NSString *)title
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler
friendCache:(FBFrictionlessRecipientCache *)friendCache;
/*!
@abstract
Presents a Facebook feed dialog.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present.
@param parameters A dictionary of additional parameters to be passed to the dialog. May be nil
@param handler An optional handler that will be called when the dialog is dismissed. May be nil.
*/
+ (void)presentFeedDialogModallyWithSession:(FBSession *)session
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler;
@end
/*!
@protocol
@abstract
The `FBWebDialogsDelegate` protocol enables the plugging of advanced behaviors into
the presentation flow of a Facebook web dialog. Advanced uses include modification
of parameters and application-level handling of links on the dialog. The
`FBFrictionlessRequestFriendCache` class implements this protocol to add frictionless
behaviors to a presentation of the request dialog.
*/
@protocol FBWebDialogsDelegate<NSObject>
@optional
/*!
@abstract
Called prior to the presentation of a web dialog
@param dialog A string representing the method or dialog name of the dialog being presented.
@param parameters A mutable dictionary of parameters which will be sent to the dialog.
@param session The session object to use with the dialog.
*/
- (void)webDialogsWillPresentDialog:(NSString *)dialog
parameters:(NSMutableDictionary *)parameters
session:(FBSession *)session;
/*!
@abstract
Called when the user of a dialog clicks a link that would cause a transition away from the application.
Your application may handle this method, and return NO if the URL handling will be performed by the application.
@param dialog A string representing the method or dialog name of the dialog being presented.
@param parameters A dictionary of parameters which were sent to the dialog.
@param session The session object to use with the dialog.
@param url The url in question, which will not be handled by the SDK if this method NO
*/
- (BOOL)webDialogsDialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
session:(FBSession *)session
shouldAutoHandleURL:(NSURL *)url;
/*!
@abstract
Called when the dialog is about to be dismissed
@param dialog A string representing the method or dialog name of the dialog being presented.
@param parameters A dictionary of parameters which were sent to the dialog.
@param session The session object to use with the dialog.
@param result A pointer to a result, which may be read or changed by the handling method as needed
@param url A pointer to a pointer to a URL representing the URL returned by the dialog, which may be read or changed by this mehthod
@param error A pointer to a pointer to an error object which may be read or changed by this method as needed
*/
- (void)webDialogsWillDismissDialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
session:(FBSession *)session
result:(FBWebDialogResult *)result
url:(NSURL **)url
error:(NSError **)error;
@end

View File

@@ -0,0 +1,281 @@
/*
* Copyright 2010-present 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 "FBFrictionlessRequestSettings.h"
#import "FBLoginDialog.h"
#import "FBRequest.h"
#import "FBSessionManualTokenCachingStrategy.h"
#import "FacebookSDK.h"
////////////////////////////////////////////////////////////////////////////////
// deprecated API
//
// Summary
// The classes, protocols, etc. in this header are provided for backward
// compatibility and migration; for new code, use FacebookSDK.h, and/or the
// public headers that it imports; for existing code under active development,
// Facebook.h imports FacebookSDK.h, and updates should favor the new interfaces
// whenever possible
// up-front decl's
@class FBFrictionlessRequestSettings;
@protocol FBRequestDelegate;
@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>{
id<FBSessionDelegate> _sessionDelegate;
NSMutableSet* _requests;
FBSession* _session;
FBSessionManualTokenCachingStrategy *_tokenCaching;
FBDialog* _fbDialog;
NSString* _appId;
NSString* _urlSchemeSuffix;
BOOL _isExtendingAccessToken;
FBRequest *_requestExtendingAccessToken;
NSDate* _lastAccessTokenUpdate;
FBFrictionlessRequestSettings* _frictionlessRequestSettings;
}
@property (nonatomic, copy) NSString* accessToken;
@property (nonatomic, copy) NSDate* expirationDate;
@property (nonatomic, assign) id<FBSessionDelegate> sessionDelegate;
@property (nonatomic, copy) NSString* urlSchemeSuffix;
@property (nonatomic, readonly) BOOL isFrictionlessRequestsEnabled;
@property (nonatomic, readonly, retain) FBSession *session;
- (id)initWithAppId:(NSString *)appId
andDelegate:(id<FBSessionDelegate>)delegate;
- (id)initWithAppId:(NSString *)appId
urlSchemeSuffix:(NSString *)urlSchemeSuffix
andDelegate:(id<FBSessionDelegate>)delegate;
- (void)authorize:(NSArray *)permissions;
- (void)extendAccessToken;
- (void)extendAccessTokenIfNeeded;
- (BOOL)shouldExtendAccessToken;
- (BOOL)handleOpenURL:(NSURL *)url;
- (void)logout;
- (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;
- (void)enableFrictionlessRequests;
- (void)reloadFrictionlessRecipientCache;
- (BOOL)isFrictionlessEnabledForRecipient:(id)fbid;
- (BOOL)isFrictionlessEnabledForRecipients:(NSArray*)fbids;
@end
////////////////////////////////////////////////////////////////////////////////
/**
* Your application should implement this delegate to receive session callbacks.
*/
@protocol FBSessionDelegate <NSObject>
/**
* Called when the user successfully logged in.
*/
- (void)fbDidLogin;
/**
* Called when the user dismissed the dialog without logging in.
*/
- (void)fbDidNotLogin:(BOOL)cancelled;
/**
* Called after the access token was extended. If your application has any
* references to the previous access token (for example, if your application
* stores the previous access token in persistent storage), your application
* should overwrite the old access token with the new one in this method.
* See extendAccessToken for more details.
*/
- (void)fbDidExtendToken:(NSString*)accessToken
expiresAt:(NSDate*)expiresAt;
/**
* Called when the user logged out.
*/
- (void)fbDidLogout;
/**
* Called when the current session has expired. This might happen when:
* - the access token expired
* - the app has been disabled
* - the user revoked the app's permissions
* - the user changed his or her password
*/
- (void)fbSessionInvalidated;
@end
@protocol FBRequestDelegate;
enum {
kFBRequestStateReady,
kFBRequestStateLoading,
kFBRequestStateComplete,
kFBRequestStateError
};
// FBRequest(Deprecated)
//
// Summary
// The deprecated category is used to maintain back compat and ease migration
// to the revised SDK for iOS
/**
* Do not use this interface directly, instead, use method in Facebook.h
*/
@interface FBRequest(Deprecated)
@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, retain) NSURLConnection* connection;
@property (nonatomic, retain) NSMutableData* responseText;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@property (nonatomic) FBRequestState state;
#pragma GCC diagnostic pop
@property (nonatomic) BOOL sessionDidExpire;
/**
* Error returned by the server in case of request's failure (or nil otherwise).
*/
@property (nonatomic, retain) NSError* error;
- (BOOL) loading;
+ (NSString *)serializeURL:(NSString *)baseUrl
params:(NSDictionary *)params;
+ (NSString*)serializeURL:(NSString *)baseUrl
params:(NSDictionary *)params
httpMethod:(NSString *)httpMethod;
@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 Facebook API request has returned a response.
*
* This callback gives you access to the raw response. It's called before
* (void)request:(FBRequest *)request didLoad:(id)result,
* which is passed the parsed response object.
*/
- (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 or a string, depending
* on the format of the API response. If you need access to the raw response,
* use:
*
* (void)request:(FBRequest *)request
* didReceiveResponse:(NSURLResponse *)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 File

@@ -0,0 +1,139 @@
/*
* Copyright 2010-present 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.
*/
// core
#import "FBAccessTokenData.h"
#import "FBAppCall.h"
#import "FBAppEvents.h"
#import "FBCacheDescriptor.h"
#import "FBDialogs.h"
#import "FBError.h"
#import "FBErrorUtility.h"
#import "FBFrictionlessRecipientCache.h"
#import "FBFriendPickerViewController.h"
#import "FBGraphLocation.h"
#import "FBGraphObject.h" // + design summary for graph component-group
#import "FBGraphPlace.h"
#import "FBGraphUser.h"
#import "FBInsights.h"
#import "FBLoginView.h"
#import "FBNativeDialogs.h" // deprecated, use FBDialogs.h
#import "FBOpenGraphAction.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBOpenGraphObject.h"
#import "FBPlacePickerViewController.h"
#import "FBProfilePictureView.h"
#import "FBRequest.h"
#import "FBSession.h"
#import "FBSessionTokenCachingStrategy.h"
#import "FBSettings.h"
#import "FBShareDialogParams.h"
#import "FBUserSettingsViewController.h"
#import "FBWebDialogs.h"
#import "NSError+FBError.h"
/*!
@header
@abstract Library header, import this to import all of the public types
in the Facebook SDK
@discussion
////////////////////////////////////////////////////////////////////////////////
Summary: this header summarizes the structure and goals of the Facebook SDK for iOS.
Goals:
* Leverage and work well with modern features of iOS (e.g. blocks, ARC, etc.)
* Patterned after best of breed iOS frameworks (e.g. naming, pattern-use, etc.)
* Common integration experience is simple & easy to describe
* Factored to enable a growing list of scenarios over time
Notes on approaches:
1. We use a key scenario to drive prioritization of work for a given update
2. We are building-atop and refactoring, rather than replacing, existing iOS SDK releases
3. We use take an incremental approach where we can choose to maintain as little or as much compatibility with the existing SDK needed
a) and so we will be developing to this approach
b) and then at push-time for a release we will decide when/what to break
on a feature by feature basis
4. Some light but critical infrastructure is needed to support both the goals
and the execution of this change (e.g. a build/package/deploy process)
Design points:
We will move to a more object-oriented approach, in order to facilitate the
addition of a different class of objects, such as controls and visual helpers
(e.g. FBLikeView, FBPersonView), as well as sub-frameworks to enable scenarios
such (e.g. FBOpenGraphEntity, FBLocalEntityCache, etc.)
As we add features, it will no longer be appropriate to host all functionality
in the Facebook class, though it will be maintained for some time for migration
purposes. Instead functionality lives in related collections of classes.
<pre>
@textblock
*------------* *----------* *----------------* *---*
Scenario --> |FBPersonView| |FBLikeView| | FBPlacePicker | | F |
*------------* *----------* *----------------* | a |
*-------------------* *----------* *--------* | c |
Component --> | FBGraphObject | | FBDialog | | FBView | | e |
*-------------------* *----------* *--------* | b |
*---------* *---------* *---------------------* | o |
Core --> |FBSession| |FBRequest| |Utilities (e.g. JSON)| | o |
*---------* *---------* *---------------------* * k *
@/textblock
</pre>
The figure above describes three layers of functionality, with the existing
Facebook on the side as a helper proxy to a subset of the overall SDK. The
layers loosely organize the SDK into *Core Objects* necessary to interface
with Facebook, higher-level *Framework Components* that feel like natural
extensions to existing frameworks such as UIKit and Foundation, but which
surface behavior broadly applicable to Facebook, and finally the
*Scenario Objects*, which provide deeper turn-key capibilities for useful
mobile scenarios.
Use example (low barrier use case):
<pre>
@textblock
// log on to Facebook
[FBSession sessionOpenWithPermissions:nil
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
if (session.isOpen) {
// request basic information for the user
[FBRequestConnection startWithGraphPath:@"me"
completionHandler:^void(FBRequestConnection *request,
id result,
NSError *error) {
if (!error) {
// get json from result
}
}];
}
}];
@/textblock
</pre>
*/
#define FB_IOS_SDK_VERSION_STRING @"3.11.1"

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2010-present 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 "FBError.h"
/*!
@category NSError(FBError)
@abstract
Adds additional properties to NSError to provide more information for Facebook related errors.
*/
@interface NSError (FBError)
/*!
@abstract
Categorizes the error, if it is Facebook related, to simplify application mitigation behavior
@discussion
In general, in response to an error connecting to Facebook, an application should, retry the
operation, request permissions, reconnect the application, or prompt the user to take an action.
The error category can be used to understand the class of error received from Facebook. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
*/
@property (readonly) FBErrorCategory fberrorCategory;
/*!
@abstract
If YES indicates that a user action is required in order to successfully continue with the facebook operation
@discussion
In general if fberrorShouldNotifyUser is NO, then the application has a straightforward mitigation, such as
retry the operation or request permissions from the user, etc. In some cases it is necessary for the user to
take an action before the application continues to attempt a Facebook connection. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
*/
@property (readonly) BOOL fberrorShouldNotifyUser;
/*!
@abstract
A message suitable for display to the user, describing a user action necessary to enable Facebook functionality.
Not all Facebook errors yield a message suitable for user display; however in all cases where
fberrorShouldNotifyUser is YES, this property returns a localizable message suitable for display.
*/
@property (readonly, copy) NSString *fberrorUserMessage;
@end

View File

@@ -0,0 +1,140 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@class FBAccessTokenData
@abstract Represents an access token used for the Facebook login flow
and includes associated metadata such as expiration date and permissions.
You should use factory methods (createToken...) to construct instances
and should be treated as immutable.
@discussion For more information, see
https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/.
*/
@interface FBAccessTokenData : NSObject <NSCopying>
/*!
@method
@abstract Creates an FBAccessTokenData from an App Link provided by the Facebook application
or nil if the url is not valid.
@param url The url provided.
@param appID needed in order to verify URL format.
@param urlSchemeSuffix needed in order to verify URL format.
*/
+ (FBAccessTokenData *) createTokenFromFacebookURL:(NSURL *)url appID:(NSString *)appID urlSchemeSuffix:(NSString *)urlSchemeSuffix;
/*!
@method
@abstract Creates an FBAccessTokenData from a dictionary or returns nil if required data is missing.
@param dictionary the dictionary with FBSessionTokenCachingStrategy keys.
*/
+ (FBAccessTokenData *) createTokenFromDictionary:(NSDictionary *)dictionary;
/*!
@method
@abstract Creates an FBAccessTokenData from existing information or returns nil if required data is missing.
@param accessToken The token string. If nil or empty, this method will return nil.
@param permissions The permissions set. A value of nil indicates basic permissions.
@param expirationDate The expiration date. A value of nil defaults to `[NSDate distantFuture]`.
@param loginType The login source of the token.
@param refreshDate The date that token was last refreshed. A value of nil defaults to `[NSDate date]`.
*/
+ (FBAccessTokenData *) createTokenFromString:(NSString *)accessToken
permissions:(NSArray *)permissions
expirationDate:(NSDate *)expirationDate
loginType:(FBSessionLoginType)loginType
refreshDate:(NSDate *)refreshDate;
/*!
@method
@abstract Creates an FBAccessTokenData from existing information or returns nil if required data is missing.
@param accessToken The token string. If nil or empty, this method will return nil.
@param permissions The permissions set. A value of nil indicates basic permissions.
@param expirationDate The expiration date. A value of nil defaults to `[NSDate distantFuture]`.
@param loginType The login source of the token.
@param refreshDate The date that token was last refreshed. A value of nil defaults to `[NSDate date]`.
@param permissionsRefreshDate The date the permissions were last refreshed. A value of nil defaults to `[NSDate distantPast]`.
*/
+ (FBAccessTokenData *) createTokenFromString:(NSString *)accessToken
permissions:(NSArray *)permissions
expirationDate:(NSDate *)expirationDate
loginType:(FBSessionLoginType)loginType
refreshDate:(NSDate *)refreshDate
permissionsRefreshDate:(NSDate *)permissionsRefreshDate;
/*!
@method
@abstract Returns a dictionary representation of this instance.
@discussion This is provided for backwards compatibility with previous
access token related APIs that used a NSDictionary (see `FBSessionTokenCachingStrategy`).
*/
- (NSMutableDictionary *) dictionary;
/*!
@method
@abstract Returns a Boolean value that indicates whether a given object is an FBAccessTokenData object and exactly equal the receiver.
@param accessTokenData the data to compare to the receiver.
*/
- (BOOL) isEqualToAccessTokenData:(FBAccessTokenData *)accessTokenData;
/*!
@abstract returns the access token NSString.
*/
@property (readonly, nonatomic, copy) NSString *accessToken;
/*!
@abstract returns the permissions associated with the access token.
*/
@property (readonly, nonatomic, copy) NSArray *permissions;
/*!
@abstract returns the expiration date of the access token.
*/
@property (readonly, nonatomic, copy) NSDate *expirationDate;
/*!
@abstract returns the login type associated with the token.
*/
@property (readonly, nonatomic) FBSessionLoginType loginType;
/*!
@abstract returns the date the token was last refreshed.
*/
@property (readonly, nonatomic, copy) NSDate *refreshDate;
/*!
@abstract returns the date the permissions were last refreshed.
*/
@property (readonly, nonatomic, copy) NSDate *permissionsRefreshDate;
@end

View File

@@ -0,0 +1,232 @@
/*
* Copyright 2010-present 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 "FBAccessTokenData.h"
#import "FBAppLinkData.h"
#import "FBDialogsData.h"
#import "FBSession.h"
@class FBAppCall;
/*!
@typedef FBAppCallHandler
@abstract
A block that is passed to performAppCall to register for a callback with the results
of that AppCall
@discussion
Pass a block of this type when calling performAppCall. This will be called on the UI
thread, once the AppCall completes.
@param call The `FBAppCall` that was completed.
*/
typedef void (^FBAppCallHandler)(FBAppCall *call);
/*!
@typedef FBAppLinkFallbackHandler
@abstract
See `+openDeferredAppLink`.
*/
typedef void (^FBAppLinkFallbackHandler)(NSError *error);
/*!
@class FBAppCall
@abstract
The FBAppCall object is used to encapsulate state when the app performs an
action that requires switching over to the native Facebook app, or when the app
receives an App Link.
@discussion
- Each FBAppCall instance will have a unique ID
- This object is passed into an FBAppCallHandler for context
- dialogData will be present if this AppCall is for a Native Dialog
- appLinkData will be present if this AppCall is for an App Link
- accessTokenData will be present if this AppCall contains an access token.
*/
@interface FBAppCall : NSObject
/*! @abstract The ID of this FBAppCall instance */
@property (nonatomic, readonly) NSString *ID;
/*! @abstract Error that occurred in processing this AppCall */
@property (nonatomic, readonly) NSError *error;
/*! @abstract Data related to a Dialog AppCall */
@property (nonatomic, readonly) FBDialogsData *dialogData;
/*! @abstract Data for native app link */
@property (nonatomic, readonly) FBAppLinkData *appLinkData;
/*! @abstract Access Token that was returned in this AppCall */
@property (nonatomic, readonly) FBAccessTokenData *accessTokenData;
/*!
@abstract
Returns an FBAppCall instance from a url, if applicable. Otherwise, returns nil.
@param url The url.
@return an FBAppCall instance if the url is valid; nil otherwise.
@discussion This is typically used for App Link URLs.
*/
+ (FBAppCall *) appCallFromURL:(NSURL *)url;
/*!
@abstract
Compares the receiving FBAppCall to the passed in FBAppCall
@param appCall the other FBAppCall to compare to.
@return YES if the AppCalls can be considered to be the same; NO if otherwise.
*/
- (BOOL)isEqualToAppCall:(FBAppCall *)appCall;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param handler Optional handler that gives the app the opportunity to do some further processing on urls
that the SDK could not completely process. A fallback handler is not a requirement for such a url to be considered
handled. The fallback handler, if specified, is only ever called sychronously, before the method returns.
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
fallbackHandler:(FBAppCallHandler)handler;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param session If this url is being sent back to this app as part of SSO authorization flow, then pass in the
session that was being opened. A nil value defaults to FBSession.activeSession
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
withSession:(FBSession *)session;
/*!
@abstract
Call this method from the [UIApplicationDelegate application:openURL:sourceApplication:annotation:] method
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
with the native Facebook app or as part of SSO authorization flow.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
@param session If this url is being sent back to this app as part of SSO authorization flow, then pass in the
session that was being opened. A nil value defaults to FBSession.activeSession
@param handler Optional handler that gives the app the opportunity to do some further processing on urls
that the SDK could not completely process. A fallback handler is not a requirement for such a url to be considered
handled. The fallback handler, if specified, is only ever called sychronously, before the method returns.
@return YES if the url was intended for the Facebook SDK, NO if not.
*/
+ (BOOL)handleOpenURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
withSession:(FBSession *)session
fallbackHandler:(FBAppCallHandler)handler;
/*!
@abstract
Call this method when the application's applicationDidBecomeActive: is invoked.
This ensures proper state management of any pending FBAppCalls or pending login flow for the
FBSession.activeSession. If any pending FBAppCalls are found, their registered callbacks
will be invoked with appropriate state
*/
+ (void)handleDidBecomeActive;
/*!
@abstract
Call this method when the application's applicationDidBecomeActive: is invoked.
This ensures proper state management of any pending FBAppCalls or a pending open for the
passed in FBSession. If any pending FBAppCalls are found, their registered callbacks will
be invoked with appropriate state
@param session Session that is currently being used. Any pending calls to open will be cancelled.
If no session is provided, then the activeSession (if present) is used.
*/
+ (void)handleDidBecomeActiveWithSession:(FBSession *)session;
/*!
@abstract
Call this method from the main thread to fetch deferred applink data. This may require
a network round trip. If successful, [+UIApplication openURL:] is invoked with the link
data. Otherwise, the fallbackHandler will be dispatched to the main thread.
@param fallbackHandler the handler to be invoked if applink data could not be opened.
@discussion the fallbackHandler may contain an NSError instance to capture any errors. In the
common case where there simply was no app link data, the NSError instance will be nil.
This method should only be called from a location that occurs after any launching URL has
been processed (e.g., you should call this method from your application delegate's applicationDidBecomeActive:)
to avoid duplicate invocations of openURL:.
If you must call this from the delegate's didFinishLaunchingWithOptions: you should
only do so if the application is not being launched by a URL. For example,
if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) {
[FBAppCall openDeferredAppLink:^(NSError *error) {
// ....
}
}
*/
+ (void)openDeferredAppLink:(FBAppLinkFallbackHandler)fallbackHandler;
@end

View File

@@ -0,0 +1,451 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@typedef FBAppEventsFlushBehavior enum
@abstract
Control when <FBAppEvents> sends log events to the server
@discussion
*/
typedef enum {
/*! Flush automatically: periodically (once a minute or every 100 logged events) and always at app reactivation. */
FBAppEventsFlushBehaviorAuto,
/*! Only flush when the `flush` method is called. When an app is moved to background/terminated, the
events are persisted and re-established at activation, but they will only be written with an
explicit call to `flush`. */
FBAppEventsFlushBehaviorExplicitOnly,
} FBAppEventsFlushBehavior;
/*
* Constant used by NSNotificationCenter for results of flushing AppEvents event logs
*/
/*! NSNotificationCenter name indicating a result of a failed log flush attempt */
extern NSString *const FBAppEventsLoggingResultNotification;
// Predefined event names for logging events common to many apps. Logging occurs through the `logEvent` family of methods on `FBAppEvents`.
// Common event parameters are provided in the `FBAppEventsParameterNames*` constants.
// General purpose
/*! Log this event when an app is being activated, typically in the AppDelegate's applicationDidBecomeActive. */
extern NSString *const FBAppEventNameActivatedApp;
/*! Log this event when a user has completed registration with the app. */
extern NSString *const FBAppEventNameCompletedRegistration;
/*! Log this event when a user has viewed a form of content in the app. */
extern NSString *const FBAppEventNameViewedContent;
/*! Log this event when a user has performed a search within the app. */
extern NSString *const FBAppEventNameSearched;
/*! Log this event when the user has rated an item in the app. The valueToSum passed to logEvent should be the numeric rating. */
extern NSString *const FBAppEventNameRated;
/*! Log this event when the user has completed a tutorial in the app. */
extern NSString *const FBAppEventNameCompletedTutorial;
// Ecommerce related
/*! Log this event when the user has added an item to their cart. The valueToSum passed to logEvent should be the item's price. */
extern NSString *const FBAppEventNameAddedToCart;
/*! Log this event when the user has added an item to their wishlist. The valueToSum passed to logEvent should be the item's price. */
extern NSString *const FBAppEventNameAddedToWishlist;
/*! Log this event when the user has entered the checkout process. The valueToSum passed to logEvent should be the total price in the cart. */
extern NSString *const FBAppEventNameInitiatedCheckout;
/*! Log this event when the user has entered their payment info. */
extern NSString *const FBAppEventNameAddedPaymentInfo;
/*! Log this event when the user has completed a purchase. The `[FBAppEvents logPurchase]` method is a shortcut for logging this event. */
extern NSString *const FBAppEventNamePurchased;
// Gaming related
/*! Log this event when the user has achieved a level in the app. */
extern NSString *const FBAppEventNameAchievedLevel;
/*! Log this event when the user has unlocked an achievement in the app. */
extern NSString *const FBAppEventNameUnlockedAchievement;
/*! Log this event when the user has spent app credits. The valueToSum passed to logEvent should be the number of credits spent. */
extern NSString *const FBAppEventNameSpentCredits;
// Predefined event name parameters for common additional information to accompany events logged through the `logEvent` family
// of methods on `FBAppEvents`. Common event names are provided in the `FBAppEventName*` constants.
/*! Parameter key used to specify currency used with logged event. E.g. "USD", "EUR", "GBP". See ISO-4217 for specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>. */
extern NSString *const FBAppEventParameterNameCurrency;
/*! Parameter key used to specify method user has used to register for the app, e.g., "Facebook", "email", "Twitter", etc */
extern NSString *const FBAppEventParameterNameRegistrationMethod;
/*! Parameter key used to specify a generic content type/family for the logged event, e.g. "music", "photo", "video". Options to use will vary based upon what the app is all about. */
extern NSString *const FBAppEventParameterNameContentType;
/*! Parameter key used to specify an ID for the specific piece of content being logged about. Could be an EAN, article identifier, etc., depending on the nature of the app. */
extern NSString *const FBAppEventParameterNameContentID;
/*! Parameter key used to specify the string provided by the user for a search operation. */
extern NSString *const FBAppEventParameterNameSearchString;
/*! Parameter key used to specify whether the activity being logged about was successful or not. `FBAppEventParameterValueYes` and `FBAppEventParameterValueNo` are good canonical values to use for this parameter. */
extern NSString *const FBAppEventParameterNameSuccess;
/*! Parameter key used to specify the maximum rating available for the `FBAppEventNameRate` event. E.g., "5" or "10". */
extern NSString *const FBAppEventParameterNameMaxRatingValue;
/*! Parameter key used to specify whether payment info is available for the `FBAppEventNameInitiatedCheckout` event. `FBAppEventParameterValueYes` and `FBAppEventParameterValueNo` are good canonical values to use for this parameter. */
extern NSString *const FBAppEventParameterNamePaymentInfoAvailable;
/*! Parameter key used to specify how many items are being processed for an `FBAppEventNameInitiatedCheckout` or `FBAppEventNamePurchased` event. */
extern NSString *const FBAppEventParameterNameNumItems;
/*! Parameter key used to specify the level achieved in a `FBAppEventNameAchieved` event. */
extern NSString *const FBAppEventParameterNameLevel;
/*! Parameter key used to specify a description appropriate to the event being logged. E.g., the name of the achievement unlocked in the `FBAppEventNameAchievementUnlocked` event. */
extern NSString *const FBAppEventParameterNameDescription;
// Predefined values to assign to event parameters that accompany events logged through the `logEvent` family
// of methods on `FBAppEvents`. Common event parameters are provided in the `FBAppEventParameterName*` constants.
/*! Yes-valued parameter value to be used with parameter keys that need a Yes/No value */
extern NSString *const FBAppEventParameterValueYes;
/*! No-valued parameter value to be used with parameter keys that need a Yes/No value */
extern NSString *const FBAppEventParameterValueNo;
/*!
@class FBAppEvents
@abstract
Client-side event logging for specialized application analytics available through Facebook App Insights
and for use with Facebook Ads conversion tracking and optimization.
@discussion
The `FBAppEvents` static class has a few related roles:
+ Logging predefined and application-defined events to Facebook App Insights with a
numeric value to sum across a large number of events, and an optional set of key/value
parameters that define "segments" for this event (e.g., 'purchaserStatus' : 'frequent', or
'gamerLevel' : 'intermediate')
+ Logging events to later be used for ads optimization around lifetime value.
+ Methods that control the way in which events are flushed out to the Facebook servers.
Here are some important characteristics of the logging mechanism provided by `FBAppEvents`:
+ Events are not sent immediately when logged. They're cached and flushed out to the Facebook servers
in a number of situations:
- when an event count threshold is passed (currently 100 logged events).
- when a time threshold is passed (currently 60 seconds).
- when an app has gone to background and is then brought back to the foreground.
+ Events will be accumulated when the app is in a disconnected state, and sent when the connection is
restored and one of the above 'flush' conditions are met.
+ The `FBAppEvents` class in thread-safe in that events may be logged from any of the app's threads.
+ The developer can set the `flushBehavior` on `FBAppEvents` to force the flushing of events to only
occur on an explicit call to the `flush` method.
+ The developer can turn on console debug output for event logging and flushing to the server by using
the `FBLoggingBehaviorAppEvents` value in `[FBSettings setLoggingBehavior:]`.
Some things to note when logging events:
+ There is a limit on the number of unique event names an app can use, on the order of 300.
+ There is a limit to the number of unique parameter names in the provided parameters that can
be used per event, on the order of 10. This is not just for an individual call, but for all
invocations for that eventName.
+ Event names and parameter names (the keys in the NSDictionary) must be between 2 and 40 characters, and
must consist of alphanumeric characters, _, -, or spaces.
+ The length of each parameter value can be no more than on the order of 100 characters.
*/
@interface FBAppEvents : NSObject
/*
* Basic event logging
*/
/*!
@method
@abstract
Log an event with just an eventName.
@param eventName The name of the event to record. Limitations on number of events and name length
are given in the `FBAppEvents` documentation.
*/
+ (void)logEvent:(NSString *)eventName;
/*!
@method
@abstract
Log an event with an eventName and a numeric value to be aggregated with other events of this name.
@param eventName The name of the event to record. Limitations on number of events and name length
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
the cumulative and average value of this amount.
*/
+ (void)logEvent:(NSString *)eventName
valueToSum:(double)valueToSum;
/*!
@method
@abstract
Log an event with an eventName and a set of key/value pairs in the parameters dictionary.
Parameter limitations are described above.
@param eventName The name of the event to record. Limitations on number of events and name construction
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
*/
+ (void)logEvent:(NSString *)eventName
parameters:(NSDictionary *)parameters;
/*!
@method
@abstract
Log an event with an eventName, a numeric value to be aggregated with other events of this name,
and a set of key/value pairs in the parameters dictionary.
@param eventName The name of the event to record. Limitations on number of events and name construction
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
the cumulative and average value of this amount.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
*/
+ (void)logEvent:(NSString *)eventName
valueToSum:(double)valueToSum
parameters:(NSDictionary *)parameters;
/*!
@method
@abstract
Log an event with an eventName, a numeric value to be aggregated with other events of this name,
and a set of key/value pairs in the parameters dictionary. Providing session lets the developer
target a particular <FBSession>. If nil is provided, then `[FBSession activeSession]` will be used.
@param eventName The name of the event to record. Limitations on number of events and name construction
are given in the `FBAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
the cumulative and average value of this amount. Note that this is an NSNumber, and a value of `nil` denotes
that this event doesn't have a value associated with it for summation.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
@param session <FBSession> to direct the event logging to, and thus be logged with whatever user (if any)
is associated with that <FBSession>.
*/
+ (void)logEvent:(NSString *)eventName
valueToSum:(NSNumber *)valueToSum
parameters:(NSDictionary *)parameters
session:(FBSession *)session;
/*
* Purchase logging
*/
/*!
@method
@abstract
Log a purchase of the specified amount, in the specified currency.
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency. This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
@discussion This event immediately triggers a flush of the `FBAppEvents` event queue, unless the `flushBehavior` is set
to `FBAppEventsFlushBehaviorExplicitOnly`.
*/
+ (void)logPurchase:(double)purchaseAmount
currency:(NSString *)currency;
/*!
@method
@abstract
Log a purchase of the specified amount, in the specified currency, also providing a set of
additional characteristics describing the purchase.
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency.This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
@discussion This event immediately triggers a flush of the `FBAppEvents` event queue, unless the `flushBehavior` is set
to `FBAppEventsFlushBehaviorExplicitOnly`.
*/
+ (void)logPurchase:(double)purchaseAmount
currency:(NSString *)currency
parameters:(NSDictionary *)parameters;
/*!
@method
@abstract
Log a purchase of the specified amount, in the specified currency, also providing a set of
additional characteristics describing the purchase, as well as an <FBSession> to log to.
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency.This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
parameters and name construction are given in the `FBAppEvents` documentation. Commonly used parameter names
are provided in `FBAppEventParameterName*` constants.
@param session <FBSession> to direct the event logging to, and thus be logged with whatever user (if any)
is associated with that <FBSession>. A value of `nil` will use `[FBSession activeSession]`.
@discussion This event immediately triggers a flush of the `FBAppEvents` event queue, unless the `flushBehavior` is set
to `FBAppEventsFlushBehaviorExplicitOnly`.
*/
+ (void)logPurchase:(double)purchaseAmount
currency:(NSString *)currency
parameters:(NSDictionary *)parameters
session:(FBSession *)session;
/*!
@method
@abstract This method has been replaced by [FBSettings limitEventAndDataUsage] */
+ (BOOL)limitEventUsage __attribute__ ((deprecated("use [FBSettings limitEventAndDataUsage] instead")));
/*!
@method
@abstract This method has been replaced by [FBSettings setLimitEventUsage] */
+ (void)setLimitEventUsage:(BOOL)limitEventUsage __attribute__ ((deprecated("use [FBSettings setLimitEventAndDataUsage] instead")));
/*!
@method
@abstract
Notifies the events system that the app has launched & logs an activatedApp event. Should typically be placed in the app delegates' `applicationDidBecomeActive:` method.
*/
+ (void)activateApp;
/*
* Control over event batching/flushing
*/
/*!
@method
@abstract
Get the current event flushing behavior specifying when events are sent back to Facebook servers.
*/
+ (FBAppEventsFlushBehavior)flushBehavior;
/*!
@method
@abstract
Set the current event flushing behavior specifying when events are sent back to Facebook servers.
@param flushBehavior The desired `FBAppEventsFlushBehavior` to be used.
*/
+ (void)setFlushBehavior:(FBAppEventsFlushBehavior)flushBehavior;
/*!
@method
@abstract
Explicitly kick off flushing of events to Facebook. This is an asynchronous method, but it does initiate an immediate
kick off. Server failures will be reported through the NotificationCenter with notification ID `FBAppEventsLoggingResultNotification`.
*/
+ (void)flush;
@end

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2010-present 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>
/*!
@abstract This class contains information that represents an App Link from Facebook.
*/
@interface FBAppLinkData : NSObject
/*! @abstract The target */
@property (readonly) NSURL *targetURL;
/*! @abstract List of the types of actions for this target */
@property (readonly) NSArray *actionTypes;
/*! @abstract List of the ids of the actions for this target */
@property (readonly) NSArray *actionIDs;
/*! @abstract Reference breadcrumb provided during creation of story */
@property (readonly) NSString *ref;
/*! @abstract User Agent string set by the referer */
@property (readonly) NSString *userAgent;
/*! @abstract Referer data is a JSON object set by the referer with referer-specific content */
@property (readonly) NSDictionary *refererData;
/*! @abstract Full set of query parameters for this app link */
@property (readonly) NSDictionary *originalQueryParameters;
/*! @abstract Original url from which applinkData was extracted */
@property (readonly) NSURL *originalURL;
/*! @abstract Addtional arguments supplied with the App Link data. */
@property (readonly) NSDictionary *arguments;
@end

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@class
@abstract
Base class from which CacheDescriptors derive, provides a method to fetch data for later use
@discussion
Cache descriptors allow your application to specify the arguments that will be
later used with another object, such as the FBFriendPickerViewController. By using a cache descriptor
instance, an application can choose to fetch data ahead of the point in time where the data is needed.
*/
@interface FBCacheDescriptor : NSObject
/*!
@method
@abstract
Fetches and caches the data described by the cache descriptor instance, for the given session.
@param session the <FBSession> to use for fetching data
*/
- (void)prefetchAndCacheForSession:(FBSession*)session;
@end

View File

@@ -0,0 +1,492 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "FBAppCall.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBShareDialogParams.h"
@class FBSession;
@protocol FBOpenGraphAction;
/*!
@typedef FBNativeDialogResult enum
@abstract
Passed to a handler to indicate the result of a dialog being displayed to the user.
*/
typedef enum {
/*! Indicates that the dialog action completed successfully. */
FBOSIntegratedShareDialogResultSucceeded = 0,
/*! Indicates that the dialog action was cancelled (either by the user or the system). */
FBOSIntegratedShareDialogResultCancelled = 1,
/*! Indicates that the dialog could not be shown (because not on ios6 or ios6 auth was not used). */
FBOSIntegratedShareDialogResultError = 2
} FBOSIntegratedShareDialogResult;
/*!
@typedef
@abstract Defines a handler that will be called in response to the native share dialog
being displayed.
*/
typedef void (^FBOSIntegratedShareDialogHandler)(FBOSIntegratedShareDialogResult result, NSError *error);
/*!
@typedef FBDialogAppCallCompletionHandler
@abstract
A block that when passed to a method in FBDialogs is called back
with the results of the AppCall for that dialog.
@discussion
This will be called on the UI thread, once the AppCall completes.
@param call The `FBAppCall` that was completed.
@param results The results of the AppCall for the dialog. This parameters is present
purely for convenience, and is the exact same value as call.dialogData.results.
@param error The `NSError` representing any error that occurred. This parameters is
present purely for convenience, and is the exact same value as call.error.
*/
typedef void (^FBDialogAppCallCompletionHandler)(
FBAppCall *call,
NSDictionary *results,
NSError *error);
/*!
@class FBDialogs
@abstract
Provides methods to display native (i.e., non-Web-based) dialogs to the user.
@discussion
If you are building an app with a urlSchemeSuffix, you should also set the appropriate
plist entry. See `[FBSettings defaultUrlSchemeSuffix]`.
*/
@interface FBDialogs : NSObject
/*!
@abstract
Presents a dialog that allows the user to share a status update that may include
text, images, or URLs. This dialog is only available on iOS 6.0 and above. The
current active session returned by [FBSession activeSession] will be used to determine
whether the dialog will be displayed. If a session is active, it must be open and the
login method used to authenticate the user must be native iOS 6.0 authentication.
If no session active, then whether the call succeeds or not will depend on
whether Facebook integration has been configured.
@param viewController The view controller which will present the dialog.
@param initialText The text which will initially be populated in the dialog. The user
will have the opportunity to edit this text before posting it. May be nil.
@param image A UIImage that will be attached to the status update. May be nil.
@param url An NSURL that will be attached to the status update. May be nil.
@param handler A handler that will be called when the dialog is dismissed, or if an error
occurs. May be nil.
@return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
will still be called, with an error indicating the reason the dialog was not displayed)
*/
+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
image:(UIImage*)image
url:(NSURL*)url
handler:(FBOSIntegratedShareDialogHandler)handler;
/*!
@abstract
Presents a dialog that allows the user to share a status update that may include
text, images, or URLs. This dialog is only available on iOS 6.0 and above. The
current active session returned by [FBSession activeSession] will be used to determine
whether the dialog will be displayed. If a session is active, it must be open and the
login method used to authenticate the user must be native iOS 6.0 authentication.
If no session active, then whether the call succeeds or not will depend on
whether Facebook integration has been configured.
@param viewController The view controller which will present the dialog.
@param initialText The text which will initially be populated in the dialog. The user
will have the opportunity to edit this text before posting it. May be nil.
@param images An array of UIImages that will be attached to the status update. May
be nil.
@param urls An array of NSURLs that will be attached to the status update. May be nil.
@param handler A handler that will be called when the dialog is dismissed, or if an error
occurs. May be nil.
@return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
will still be called, with an error indicating the reason the dialog was not displayed)
*/
+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBOSIntegratedShareDialogHandler)handler;
/*!
@abstract
Presents a dialog that allows the user to share a status update that may include
text, images, or URLs. This dialog is only available on iOS 6.0 and above. An
<FBSession> may be specified, or nil may be passed to indicate that the current
active session should be used. If a session is specified (whether explicitly or by
virtue of being the active session), it must be open and the login method used to
authenticate the user must be native iOS 6.0 authentication. If no session is specified
(and there is no active session), then whether the call succeeds or not will depend on
whether Facebook integration has been configured.
@param viewController The view controller which will present the dialog.
@param session The <FBSession> to use to determine whether or not the user has been
authenticated with iOS native authentication. If nil, then [FBSession activeSession]
will be checked. See discussion above for the implications of nil or non-nil session.
@param initialText The text which will initially be populated in the dialog. The user
will have the opportunity to edit this text before posting it. May be nil.
@param images An array of UIImages that will be attached to the status update. May
be nil.
@param urls An array of NSURLs that will be attached to the status update. May be nil.
@param handler A handler that will be called when the dialog is dismissed, or if an error
occurs. May be nil.
@return YES if the dialog was presented, NO if not (in the case of a NO result, the handler
will still be called, with an error indicating the reason the dialog was not displayed)
*/
+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
session:(FBSession*)session
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBOSIntegratedShareDialogHandler)handler;
/*!
@abstract
Determines whether a call to presentShareDialogModallyFrom: will successfully present
a dialog. This is useful for applications that need to modify the available UI controls
depending on whether the dialog is available on the current platform and for the current
user.
@param session The <FBSession> to use to determine whether or not the user has been
authenticated with iOS native authentication. If nil, then [FBSession activeSession]
will be checked. See discussion above for the implications of nil or non-nil session.
@return YES if the dialog would be presented for the session, and NO if not
*/
+ (BOOL)canPresentOSIntegratedShareDialogWithSession:(FBSession*)session;
/*!
@abstract
Determines whether a call to presentShareDialogWithTarget: will successfully
present a dialog in the Facebook application. This is useful for applications that
need to modify the available UI controls depending on whether the dialog is
available on the current platform.
@param params The parameters for the FB share dialog.
@return YES if the dialog would be presented, and NO if not
@discussion A return value of YES here indicates that the corresponding
presentShareDialogWithParams method will return a non-nil FBAppCall for the same
params. And vice versa.
*/
+ (BOOL)canPresentShareDialogWithParams:(FBShareDialogParams *)params;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share a status
update that may include text, images, or URLs. No session is required, and the app
does not need to be authorized to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param params The parameters for the FB share dialog.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share the
supplied link. No session is required, and the app does not need to be authorized
to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param link The URL link to be attached to the post.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share the
supplied link. No session is required, and the app does not need to be authorized
to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param link The URL link to be attached to the post.
@param name The name, or title associated with the link. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
name:(NSString *)name
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to share the
supplied link. No session is required, and the app does not need to be authorized
to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param link The URL link to be attached to the post.
@param name The name, or title associated with the link. May be nil.
@param caption The caption to be used with the link. May be nil.
@param description The description associated with the link. May be nil.
@param picture The link to a thumbnail to associate with the link. May be nil.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
name:(NSString *)name
caption:(NSString *)caption
description:(NSString *)description
picture:(NSURL *)picture
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Determines whether a call to presentShareDialogWithOpenGraphActionParams:clientState:handler:
will successfully present a dialog in the Facebook application. This is useful for applications
that need to modify the available UI controls depending on whether the dialog is
available on the current platform.
@param params The parameters for the FB share dialog.
@return YES if the dialog would be presented, and NO if not
@discussion A return value of YES here indicates that the corresponding
presentShareDialogWithOpenGraphActionParams method will return a non-nil FBAppCall for
the same params. And vice versa.
*/
+ (BOOL)canPresentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionShareDialogParams *)params;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to publish an Open
Graph action. No session is required, and the app does not need to be authorized to call
this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param params The parameters for the Open Graph action dialog.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionShareDialogParams *)params
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler)handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to publish the
supplied Open Graph action. No session is required, and the app does not need to be
authorized to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param action The Open Graph action to be published. May not be nil.
@param actionType the fully-specified Open Graph action type of the action (e.g.,
my_app_namespace:my_action).
@param previewPropertyName the name of the property on the action that represents the
primary Open Graph object associated with the action; this object will be displayed in the
preview portion of the share dialog.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
actionType:(NSString *)actionType
previewPropertyName:(NSString *)previewPropertyName
handler:(FBDialogAppCallCompletionHandler) handler;
/*!
@abstract
Presents a dialog in the Facebook application that allows the user to publish the
supplied Open Graph action. No session is required, and the app does not need to be
authorized to call this.
Note that this will perform an app switch to the Facebook app, and will cause the
current app to be suspended. When the share is complete, the Facebook app will redirect
to a url of the form "fb{APP_ID}://" that the application must handle. The app should
then call [FBAppCall handleOpenURL:sourceApplication:fallbackHandler:] to trigger
the appropriate handling. Note that FBAppCall will first try to call the completion
handler associated with this method, but since during an app switch, the calling app
may be suspended or killed, the app must also give a fallbackHandler to the
handleOpenURL: method in FBAppCall.
@param action The Open Graph action to be published. May not be nil.
@param actionType the fully-specified Open Graph action type of the action (e.g.,
my_app_namespace:my_action).
@param previewPropertyName the name of the property on the action that represents the
primary Open Graph object associated with the action; this object will be displayed in the
preview portion of the share dialog.
@param clientState An NSDictionary that's passed through when the completion handler
is called. This is useful for the app to maintain state about the share request that
was made so as to have appropriate action when the handler is called. May be nil.
@param handler A completion handler that may be called when the status update is
complete. May be nil. If non-nil, the handler will always be called asynchronously.
@return An FBAppCall object that will also be passed into the provided
FBAppCallCompletionHandler.
@discussion A non-nil FBAppCall object is only returned if the corresponding
canPresentShareDialogWithOpenGraphActionParams method is also returning YES for the same params.
*/
+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
actionType:(NSString *)actionType
previewPropertyName:(NSString *)previewPropertyName
clientState:(NSDictionary *)clientState
handler:(FBDialogAppCallCompletionHandler) handler;
@end

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2010-present 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>
/*!
@abstract
This class encapsulates state and data related to the presentation and completion
of a dialog.
*/
@interface FBDialogsData : NSObject
/*! @abstract The method being performed */
@property (nonatomic, readonly) NSString *method;
/*! @abstract The arguments being passed to the entity that will show the dialog */
@property (nonatomic, readonly) NSDictionary *arguments;
/*! @abstract Client JSON state that is passed through to the completion handler for context */
@property (nonatomic, readonly) NSDictionary *clientState;
/*! @abstract Results of this FBAppCall that are only set before calling an FBAppCallHandler */
@property (nonatomic, readonly) NSDictionary *results;
@end

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2010-present 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>
/*!
@class FBDialogsParams
@abstract
This object is used as a base class for parameters passed to native dialogs that
open in the Facebook app.
*/
@interface FBDialogsParams : NSObject
@end

View File

@@ -0,0 +1,372 @@
/*
* Copyright 2010-present 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>
/*!
The NSError domain of all errors returned by the Facebook SDK.
*/
extern NSString *const FacebookSDKDomain;
/*!
The NSError domain of all errors surfaced by the Facebook SDK that
were returned by the Facebook Application
*/
extern NSString *const FacebookNativeApplicationDomain;
/*!
The key in the userInfo NSDictionary of NSError where you can find
the inner NSError (if any).
*/
extern NSString *const FBErrorInnerErrorKey;
/*!
The key in the userInfo NSDictionary of NSError for the parsed JSON response
from the server. In case of a batch, includes the JSON for a single FBRequest.
*/
extern NSString *const FBErrorParsedJSONResponseKey;
/*!
The key in the userInfo NSDictionary of NSError indicating
the HTTP status code of the response (if any).
*/
extern NSString *const FBErrorHTTPStatusCodeKey;
/*!
@abstract Error codes returned by the Facebook SDK in NSError.
@discussion
These are valid only in the scope of FacebookSDKDomain.
*/
typedef enum FBErrorCode {
/*!
Like nil for FBErrorCode values, represents an error code that
has not been initialized yet.
*/
FBErrorInvalid = 0,
/// The operation failed because it was cancelled.
FBErrorOperationCancelled,
/// A login attempt failed
FBErrorLoginFailedOrCancelled,
/// The graph API returned an error for this operation.
FBErrorRequestConnectionApi,
/*!
The operation failed because the server returned an unexpected
response. You can get this error if you are not using the most
recent SDK, or if you set your application's migration settings
incorrectly for the version of the SDK you are using.
If this occurs on the current SDK with proper app migration
settings, you may need to try changing to one request per batch.
*/
FBErrorProtocolMismatch,
/// Non-success HTTP status code was returned from the operation.
FBErrorHTTPError,
/// An endpoint that returns a binary response was used with FBRequestConnection;
/// endpoints that return image/jpg, etc. should be accessed using NSURLRequest
FBErrorNonTextMimeTypeReturned,
/// An error occurred while trying to display a native dialog
FBErrorDialog,
/// An error occurred using the FBAppEvents class
FBErrorAppEvents,
/// An error occurred related to an iOS API call
FBErrorSystemAPI,
/// An error occurred while trying to fetch publish install response data
FBErrorPublishInstallResponse,
/*!
The application had its applicationDidBecomeActive: method called while waiting
on a response from the native Facebook app for a pending FBAppCall.
*/
FBErrorAppActivatedWhilePendingAppCall,
/*!
The application had its openURL: method called from a source that was not a
Facebook app and with a URL that was intended for the AppBridge
*/
FBErrorUntrustedURL,
/*!
The URL passed to FBAppCall, was not able to be parsed
*/
FBErrorMalformedURL,
/*!
The operation failed because the session is currently busy reconnecting.
*/
FBErrorSessionReconnectInProgess,
/*!
Reserved for future use.
*/
FBErrorOperationDisallowedForRestrictedTreament,
} FBErrorCode;
/*!
@abstract Error codes returned by the Facebook SDK in NSError.
@discussion
These are valid only in the scope of FacebookNativeApplicationDomain.
*/
typedef enum FBNativeApplicationErrorCode {
// A general error in processing an FBAppCall, without a known cause. Unhandled exceptions are a good example
FBAppCallErrorUnknown = 1,
// The FBAppCall cannot be processed for some reason
FBAppCallErrorUnsupported = 2,
// The FBAppCall is for a method that does not exist (or is turned off)
FBAppCallErrorUnknownMethod = 3,
// The FBAppCall cannot be processed at the moment, but can be retried at a later time.
FBAppCallErrorServiceBusy = 4,
// Share was called in the native Facebook app with incomplete or incorrect arguments
FBShareErrorInvalidParam = 100,
// A server error occurred while calling Share in the native Facebook app.
FBShareErrorServer = 102,
// An unknown error occurred while calling Share in the native Facebook app.
FBShareErrorUnknown = 103,
// Disallowed from calling Share in the native Facebook app.
FBShareErrorDenied = 104,
} FBNativeApplicationErrorCode;
/*!
@typedef FBErrorCategory enum
@abstract Indicates the Facebook SDK classification for the error
@discussion
*/
typedef enum {
/*! Indicates that the error category is invalid and likely represents an error that
is unrelated to Facebook or the Facebook SDK */
FBErrorCategoryInvalid = 0,
/*! Indicates that the error may be authentication related but the application should retry the operation.
This case may involve user action that must be taken, and so the application should also test
the fberrorShouldNotifyUser property and if YES display fberrorUserMessage to the user before retrying.*/
FBErrorCategoryRetry = 1,
/*! Indicates that the error is authentication related and the application should reopen the session*/
FBErrorCategoryAuthenticationReopenSession = 2,
/*! Indicates that the error is permission related */
FBErrorCategoryPermissions = 3,
/*! Indicates that the error implies that the server had an unexpected failure or may be temporarily down */
FBErrorCategoryServer = 4,
/*! Indicates that the error results from the server throttling the client */
FBErrorCategoryThrottling = 5,
/*! Indicates the user cancelled the operation */
FBErrorCategoryUserCancelled = 6,
/*! Indicates that the error is Facebook-related but is uncategorizable, and likely newer than the
current version of the SDK */
FBErrorCategoryFacebookOther = -1,
/*! Indicates that the error is an application error resulting in a bad or malformed request to the server. */
FBErrorCategoryBadRequest = -2,
} FBErrorCategory;
/*!
The key in the userInfo NSDictionary of NSError where you can find
the inner NSError (if any).
*/
extern NSString *const FBErrorInnerErrorKey;
/*!
The key in the userInfo NSDictionary of NSError where you can find
the session associated with the error (if any).
*/
extern NSString *const FBErrorSessionKey;
/*!
The key in the userInfo NSDictionary of NSError that points to the URL
that caused an error, in its processing by FBAppCall.
*/
extern NSString *const FBErrorUnprocessedURLKey;
/*!
The key in the userInfo NSDictionary of NSError for unsuccessful
logins (error.code equals FBErrorLoginFailedOrCancelled). If present,
the value will be one of the constants prefixed by FBErrorLoginFailedReason*.
*/
extern NSString *const FBErrorLoginFailedReason;
/*!
The key in the userInfo NSDictionary of NSError for unsuccessful
logins (error.code equals FBErrorLoginFailedOrCancelled). If present,
the value indicates an original login error code wrapped by this error.
This is only used in the web dialog login flow.
*/
extern NSString *const FBErrorLoginFailedOriginalErrorCode;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
cancelled a web dialog auth.
*/
extern NSString *const FBErrorLoginFailedReasonInlineCancelledValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
did not cancel a web dialog auth.
*/
extern NSString *const FBErrorLoginFailedReasonInlineNotCancelledValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
cancelled a non-iOS 6 SSO (either Safari or Facebook App) login.
*/
extern NSString *const FBErrorLoginFailedReasonUserCancelledValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the user
cancelled an iOS system login.
*/
extern NSString *const FBErrorLoginFailedReasonUserCancelledSystemValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates an error
condition. You may inspect the rest of userInfo for other data.
*/
extern NSString *const FBErrorLoginFailedReasonOtherError;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates the app's
slider in iOS 6 (device Settings -> Privacy -> Facebook {app} ) has
been disabled.
*/
extern NSString *const FBErrorLoginFailedReasonSystemDisallowedWithoutErrorValue;
/*!
A value that may appear in an NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key for login failures. Indicates an error
has occurred when requesting Facebook account acccess in iOS 6 that was
not `FBErrorLoginFailedReasonSystemDisallowedWithoutErrorValue` nor
a user cancellation.
*/
extern NSString *const FBErrorLoginFailedReasonSystemError;
extern NSString *const FBErrorLoginFailedReasonUnitTestResponseUnrecognized;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails. Indicates
the request for new permissions has failed because the session was closed.
*/
extern NSString *const FBErrorReauthorizeFailedReasonSessionClosed;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails. Indicates
the request for new permissions has failed because the user cancelled.
*/
extern NSString *const FBErrorReauthorizeFailedReasonUserCancelled;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails on
iOS 6 with the Facebook account. Indicates the request for new permissions has
failed because the user cancelled.
*/
extern NSString *const FBErrorReauthorizeFailedReasonUserCancelledSystem;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorLoginFailedReason` key when requesting new permissions fails. Indicates
the request for new permissions has failed because the request was
for a different user than the original permission set.
*/
extern NSString *const FBErrorReauthorizeFailedReasonWrongUser;
/*!
The key in the userInfo NSDictionary of NSError for errors
encountered with `FBDialogs` operations. (error.code equals FBErrorDialog).
If present, the value will be one of the constants prefixed by FBErrorDialog*.
*/
extern NSString *const FBErrorDialogReasonKey;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog is not supported
in the current OS.
*/
extern NSString *const FBErrorDialogNotSupported;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed because it is not appropriate for the current session.
*/
extern NSString *const FBErrorDialogInvalidForSession;
/*!
A value that may appear in the NSError userInfo dictionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed for some other reason.
*/
extern NSString *const FBErrorDialogCantBeDisplayed;
/*!
A value that may appear in the NSError userInfo ditionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed because an Open Graph object that was passed was not configured
correctly. The object must either (a) exist by having an 'id' or 'url' value;
or, (b) configured for creation (by setting the 'type' value and
provisionedForPost property)
*/
extern NSString *const FBErrorDialogInvalidOpenGraphObject;
/*!
A value that may appear in the NSError userInfo ditionary under the
`FBErrorDialogReasonKey` key. Indicates that a native dialog cannot be
displayed because the parameters for sharing an Open Graph action were
not configured. The parameters must include an 'action', 'actionType', and
'previewPropertyName'.
*/
extern NSString *const FBErrorDialogInvalidOpenGraphActionParameters;
/*!
The key in the userInfo NSDictionary of NSError for errors
encountered with `FBAppEvents` operations (error.code equals FBErrorAppEvents).
*/
extern NSString *const FBErrorAppEventsReasonKey;
// Exception strings raised by the Facebook SDK
/*!
This exception is raised by methods in the Facebook SDK to indicate
that an attempted operation is invalid
*/
extern NSString *const FBInvalidOperationException;
// Facebook SDK also raises exceptions the following common exceptions:
// NSInvalidArgumentException

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2010-present 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.
*/
/*!
@class FBErrorUtility
@abstract A utility class with methods to provide more information for Facebook
related errors if you do not want to use the NSError(FBError) category.
*/
@interface FBErrorUtility : NSObject
/*!
@abstract
Categorizes the error, if it is Facebook related, to simplify application mitigation behavior
@discussion
In general, in response to an error connecting to Facebook, an application should, retry the
operation, request permissions, reconnect the application, or prompt the user to take an action.
The error category can be used to understand the class of error received from Facebook. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
@param error the error to be categorized.
*/
+(FBErrorCategory) errorCategoryForError:(NSError *)error;
/*!
@abstract
If YES indicates that a user action is required in order to successfully continue with the facebook operation
@discussion
In general if this returns NO, then the application has a straightforward mitigation, such as
retry the operation or request permissions from the user, etc. In some cases it is necessary for the user to
take an action before the application continues to attempt a Facebook connection. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
@param error the error to inspect.
*/
+(BOOL) shouldNotifyUserForError:(NSError *)error;
/*!
@abstract
A message suitable for display to the user, describing a user action necessary to enable Facebook functionality.
Not all Facebook errors yield a message suitable for user display; however in all cases where
fberrorShouldNotifyUser is YES, this property returns a localizable message suitable for display.
@param error the error to inspect.
*/
+(NSString *) userMessageForError:(NSError *)error;
@end

View File

@@ -0,0 +1,87 @@
/*
* Copyright 2010-present 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 "FBCacheDescriptor.h"
#import "FBRequest.h"
#import "FBWebDialogs.h"
/*!
@class FBFrictionlessRecipientCache
@abstract
Maintains a cache of friends that can recieve application requests from the user in
using the frictionless feature of the requests web dialog.
This class follows the `FBCacheDescriptor` pattern used elsewhere in the SDK, and applications may call
one of the prefetchAndCacheForSession methods to fetch a friend list prior to the
point where a dialog is presented. The cache is also updated with each presentation of the request
dialog using the cache instance.
*/
@interface FBFrictionlessRecipientCache : FBCacheDescriptor<FBWebDialogsDelegate>
/*!
@abstract
Initializes an empty cache instance
*/
- (id)init;
/*! @abstract An array containing the list of known FBIDs for recipients enabled for frictionless requests */
@property (nonatomic, readwrite, copy) NSArray *recipientIDs;
/*!
@abstract
Checks to see if a given user or FBID for a user is known to be enabled for
frictionless requestests
@param user An NSString, NSNumber of `FBGraphUser` representing a user to check
*/
- (BOOL)isFrictionlessRecipient:(id)user;
/*!
@abstract
Checks to see if a collection of users or FBIDs for users are known to be enabled for
frictionless requestests
@param users An NSArray of NSString, NSNumber of `FBGraphUser` objects
representing users to check
*/
- (BOOL)areFrictionlessRecipients:(NSArray*)users;
/*!
@abstract
Issues a request and fills the cache with a list of users to use for frictionless requests
@param session The session to use for the request; nil indicates that the Active Session should
be used
*/
- (void)prefetchAndCacheForSession:(FBSession *)session;
/*!
@abstract
Issues a request and fills the cache with a list of users to use for frictionless requests
@param session The session to use for the request; nil indicates that the Active Session should
be used
@param handler An optional completion handler, called when the request for cached users has
completed. It can be useful to use the handler to enable UI or perform other request-related
operations, after the cache is populated.
*/
- (void)prefetchAndCacheForSession:(FBSession *)session
completionHandler:(FBRequestHandler)handler;
@end

View File

@@ -0,0 +1,296 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
#import "FBCacheDescriptor.h"
#import "FBGraphUser.h"
#import "FBSession.h"
#import "FBViewController.h"
@protocol FBFriendPickerDelegate;
@class FBFriendPickerCacheDescriptor;
/*!
@typedef FBFriendSortOrdering enum
@abstract Indicates the order in which friends should be listed in the friend picker.
@discussion
*/
typedef enum {
/*! Sort friends by first, middle, last names. */
FBFriendSortByFirstName,
/*! Sort friends by last, first, middle names. */
FBFriendSortByLastName
} FBFriendSortOrdering;
/*!
@typedef FBFriendDisplayOrdering enum
@abstract Indicates whether friends should be displayed first-name-first or last-name-first.
@discussion
*/
typedef enum {
/*! Display friends as First Middle Last. */
FBFriendDisplayByFirstName,
/*! Display friends as Last First Middle. */
FBFriendDisplayByLastName,
} FBFriendDisplayOrdering;
/*!
@class
@abstract
The `FBFriendPickerViewController` class creates a controller object that manages
the user interface for displaying and selecting Facebook friends.
@discussion
When the `FBFriendPickerViewController` view loads it creates a `UITableView` object
where the friends will be displayed. You can access this view through the `tableView`
property. The friend display can be sorted by first name or last name. Friends'
names can be displayed with the first name first or the last name first.
The friend data can be pre-fetched and cached prior to using the view controller. The
cache is setup using an <FBCacheDescriptor> object that can trigger the
data fetch. Any friend data requests will first check the cache and use that data.
If the friend picker is being displayed cached data will initially be shown before
a fresh copy is retrieved.
The `delegate` property may be set to an object that conforms to the <FBFriendPickerDelegate>
protocol. The `delegate` object will receive updates related to friend selection and
data changes. The delegate can also be used to filter the friends to display in the
picker.
*/
@interface FBFriendPickerViewController : FBViewController
/*!
@abstract
Returns an outlet for the spinner used in the view controller.
*/
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner;
/*!
@abstract
Returns an outlet for the table view managed by the view controller.
*/
@property (nonatomic, retain) IBOutlet UITableView *tableView;
/*!
@abstract
A Boolean value that specifies whether multi-select is enabled.
*/
@property (nonatomic) BOOL allowsMultipleSelection;
/*!
@abstract
A Boolean value that indicates whether friend profile pictures are displayed.
*/
@property (nonatomic) BOOL itemPicturesEnabled;
/*!
@abstract
Addtional fields to fetch when making the Graph API call to get friend data.
*/
@property (nonatomic, copy) NSSet *fieldsForRequest;
/*!
@abstract
The session that is used in the request for friend data.
*/
@property (nonatomic, retain) FBSession *session;
/*!
@abstract
The profile ID of the user whose friends are being viewed.
*/
@property (nonatomic, copy) NSString *userID;
/*!
@abstract
The list of friends that are currently selected in the veiw.
The items in the array are <FBGraphUser> objects.
@discussion
You can set this this array to pre-select items in the picker. The objects in the array
must be complete id<FBGraphUser> objects (i.e., fetched from a Graph query or from a
previous picker's selection, with id and appropriate name fields).
*/
@property (nonatomic, copy) NSArray *selection;
/*!
@abstract
The order in which friends are sorted in the display.
*/
@property (nonatomic) FBFriendSortOrdering sortOrdering;
/*!
@abstract
The order in which friends' names are displayed.
*/
@property (nonatomic) FBFriendDisplayOrdering displayOrdering;
/*!
@abstract
Initializes a friend picker view controller.
*/
- (id)init;
/*!
@abstract
Initializes a friend picker view controller.
@param aDecoder An unarchiver object.
*/
- (id)initWithCoder:(NSCoder *)aDecoder;
/*!
@abstract
Used to initialize the object
@param nibNameOrNil The name of the nib file to associate with the view controller. The nib file name should not contain any leading path information. If you specify nil, the nibName property is set to nil.
@param nibBundleOrNil The bundle in which to search for the nib file. This method looks for the nib file in the bundle's language-specific project directories first, followed by the Resources directory. If nil, this method looks for the nib file in the main bundle.
*/
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
/*!
@abstract
Configures the properties used in the caching data queries.
@discussion
Cache descriptors are used to fetch and cache the data used by the view controller.
If the view controller finds a cached copy of the data, it will
first display the cached content then fetch a fresh copy from the server.
@param cacheDescriptor The <FBCacheDescriptor> containing the cache query properties.
*/
- (void)configureUsingCachedDescriptor:(FBCacheDescriptor*)cacheDescriptor;
/*!
@abstract
Initiates a query to get friend data.
@discussion
A cached copy will be returned if available. The cached view is temporary until a fresh copy is
retrieved from the server. It is legal to call this more than once.
*/
- (void)loadData;
/*!
@abstract
Updates the view locally without fetching data from the server or from cache.
@discussion
Use this if the filter or sort properties change. This may affect the order or
display of friend information but should not need require new data.
*/
- (void)updateView;
/*!
@abstract
Clears the current selection, so the picker is ready for a fresh use.
*/
- (void)clearSelection;
/*!
@method
@abstract
Creates a cache descriptor based on default settings of the `FBFriendPickerViewController` object.
@discussion
An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
the view controller. It may also be used to configure the `FBFriendPickerViewController`
object.
*/
+ (FBCacheDescriptor*)cacheDescriptor;
/*!
@method
@abstract
Creates a cache descriptor with additional fields and a profile ID for use with the `FBFriendPickerViewController` object.
@discussion
An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
the view controller. It may also be used to configure the `FBFriendPickerViewController`
object.
@param userID The profile ID of the user whose friends will be displayed. A nil value implies a "me" alias.
@param fieldsForRequest The set of additional fields to include in the request for friend data.
*/
+ (FBCacheDescriptor*)cacheDescriptorWithUserID:(NSString*)userID fieldsForRequest:(NSSet*)fieldsForRequest;
@end
/*!
@protocol
@abstract
The `FBFriendPickerDelegate` protocol defines the methods used to receive event
notifications and allow for deeper control of the <FBFriendPickerViewController>
view.
*/
@protocol FBFriendPickerDelegate <FBViewControllerDelegate>
@optional
/*!
@abstract
Tells the delegate that data has been loaded.
@discussion
The <FBFriendPickerViewController> object's `tableView` property is automatically
reloaded when this happens. However, if another table view, for example the
`UISearchBar` is showing data, then it may also need to be reloaded.
@param friendPicker The friend picker view controller whose data changed.
*/
- (void)friendPickerViewControllerDataDidChange:(FBFriendPickerViewController *)friendPicker;
/*!
@abstract
Tells the delegate that the selection has changed.
@param friendPicker The friend picker view controller whose selection changed.
*/
- (void)friendPickerViewControllerSelectionDidChange:(FBFriendPickerViewController *)friendPicker;
/*!
@abstract
Asks the delegate whether to include a friend in the list.
@discussion
This can be used to implement a search bar that filters the friend list.
@param friendPicker The friend picker view controller that is requesting this information.
@param user An <FBGraphUser> object representing the friend.
*/
- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
shouldIncludeUser:(id <FBGraphUser>)user;
/*!
@abstract
Tells the delegate that there is a communication error.
@param friendPicker The friend picker view controller that encountered the error.
@param error An error object containing details of the error.
*/
- (void)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
handleError:(NSError *)error;
@end

View File

@@ -0,0 +1,78 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
/*!
@protocol
@abstract
The `FBGraphLocation` protocol enables typed access to the `location` property
of a Facebook place object.
@discussion
The `FBGraphLocation` protocol represents the most commonly used properties of a
location object. It may be used to access an `NSDictionary` object that has
been wrapped with an <FBGraphObject> facade.
*/
@protocol FBGraphLocation<FBGraphObject>
/*!
@property
@abstract Typed access to a location's street.
*/
@property (retain, nonatomic) NSString *street;
/*!
@property
@abstract Typed access to a location's city.
*/
@property (retain, nonatomic) NSString *city;
/*!
@property
@abstract Typed access to a location's state.
*/
@property (retain, nonatomic) NSString *state;
/*!
@property
@abstract Typed access to a location's country.
*/
@property (retain, nonatomic) NSString *country;
/*!
@property
@abstract Typed access to a location's zip code.
*/
@property (retain, nonatomic) NSString *zip;
/*!
@property
@abstract Typed access to a location's latitude.
*/
@property (retain, nonatomic) NSNumber *latitude;
/*!
@property
@abstract Typed access to a location's longitude.
*/
@property (retain, nonatomic) NSNumber *longitude;
@end

View File

@@ -0,0 +1,269 @@
/*
* Copyright 2010-present 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>
@protocol FBOpenGraphObject;
@protocol FBOpenGraphAction;
/*!
@protocol
@abstract
The `FBGraphObject` protocol is the base protocol which enables typed access to graph objects and
open graph objects. Inherit from this protocol or a sub-protocol in order to introduce custom types
for typed access to Facebook objects.
@discussion
The `FBGraphObject` protocol is the core type used by the Facebook SDK for iOS to
represent objects in the Facebook Social Graph and the Facebook Open Graph (OG).
The `FBGraphObject` class implements useful default functionality, but is rarely
used directly by applications. The `FBGraphObject` protocol, in contrast is the
base protocol for all graph object access via the SDK.
Goals of the FBGraphObject types:
<ul>
<li> Lightweight/maintainable/robust </li>
<li> Extensible and resilient to change, both by Facebook and third party (OG) </li>
<li> Simple and natural extension to Objective-C </li>
</ul>
The FBGraphObject at its core is a duck typed (if it walks/swims/quacks...
its a duck) model which supports an optional static facade. Duck-typing achieves
the flexibility necessary for Social Graph and OG uses, and the static facade
increases discoverability, maintainability, robustness and simplicity.
The following excerpt from the PlacePickerSample shows a simple use of the
a facade protocol `FBGraphPlace` by an application:
<pre>
&dash; (void)placePickerViewControllerSelectionDidChange:(FBPlacePickerViewController *)placePicker
{
id&#060;FBGraphPlace&#062; place = placePicker.selection;
// we'll use logging to show the simple typed property access to place and location info
NSLog(@"place=%@, city=%@, state=%@, lat long=%@ %@",
place.name,
place.location.city,
place.location.state,
place.location.latitude,
place.location.longitude);
}
</pre>
Note that in this example, access to common place information is available through typed property
syntax. But if at some point places in the Social Graph supported additional fields "foo" and "bar", not
reflected in the `FBGraphPlace` protocol, the application could still access the values like so:
<pre>
NSString *foo = [place objectForKey:@"foo"]; // perhaps located at the ... in the preceding example
NSNumber *bar = [place objectForKey:@"bar"]; // extensibility applies to Social and Open graph uses
</pre>
In addition to untyped access, applications and future revisions of the SDK may add facade protocols by
declaring a protocol inheriting the `FBGraphObject` protocol, like so:
<pre>
&#064;protocol MyGraphThing&#060;FBGraphObject&#062;
&#064;property (copy, nonatomic) NSString *id;
&#064;property (copy, nonatomic) NSString *name;
&#064;end
</pre>
Important: facade implementations are inferred by graph objects returned by the methods of the SDK. This
means that no explicit implementation is required by application or SDK code. Any `FBGraphObject` instance
may be cast to any `FBGraphObject` facade protocol, and accessed via properties. If a field is not present
for a given facade property, the property will return nil.
The following layer diagram depicts some of the concepts discussed thus far:
<pre>
*-------------* *------------* *-------------**--------------------------*
Facade --> | FBGraphUser | |FBGraphPlace| | MyGraphThing|| MyGraphPersonExtentension| ...
*-------------* *------------* *-------------**--------------------------*
*------------------------------------* *--------------------------------------*
Transparent impl --> | FBGraphObject (instances) | | CustomClass&#060;FBGraphObject&#062; |
*------------------------------------* *--------------------------------------*
*-------------------**------------------------* *-----------------------------*
Apparent impl --> |NSMutableDictionary||FBGraphObject (protocol)| |FBGraphObject (class methods)|
*-------------------**------------------------* *-----------------------------*
</pre>
The *Facade* layer is meant for typed access to graph objects. The *Transparent impl* layer (more
specifically, the instance capabilities of `FBGraphObject`) are used by the SDK and app logic
internally, but are not part of the public interface between application and SDK. The *Apparent impl*
layer represents the lower-level "duck-typed" use of graph objects.
Implementation note: the SDK returns `NSMutableDictionary` derived instances with types declared like
one of the following:
<pre>
NSMutableDictionary&#060;FBGraphObject&#062; *obj; // no facade specified (still castable by app)
NSMutableDictionary&#060;FBGraphPlace&#062; *person; // facade specified when possible
</pre>
However, when passing a graph object to the SDK, `NSMutableDictionary` is not assumed; only the
FBGraphObject protocol is assumed, like so:
<pre>
id&#060;FBGraphObject&#062; anyGraphObj;
</pre>
As such, the methods declared on the `FBGraphObject` protocol represent the methods used by the SDK to
consume graph objects. While the `FBGraphObject` class implements the full `NSMutableDictionary` and KVC
interfaces, these are not consumed directly by the SDK, and are optional for custom implementations.
*/
@protocol FBGraphObject<NSObject>
/*!
@method
@abstract
Returns the number of properties on this `FBGraphObject`.
*/
- (NSUInteger)count;
/*!
@method
@abstract
Returns a property on this `FBGraphObject`.
@param aKey name of the property to return
*/
- (id)objectForKey:(id)aKey;
/*!
@method
@abstract
Returns an enumerator of the property naems on this `FBGraphObject`.
*/
- (NSEnumerator *)keyEnumerator;
/*!
@method
@abstract
Removes a property on this `FBGraphObject`.
@param aKey name of the property to remove
*/
- (void)removeObjectForKey:(id)aKey;
/*!
@method
@abstract
Sets the value of a property on this `FBGraphObject`.
@param anObject the new value of the property
@param aKey name of the property to set
*/
- (void)setObject:(id)anObject forKey:(id)aKey;
@optional
/*!
@abstract
This property signifies that the current graph object is provisioned for POST (as a definition
for a new or updated graph object), and should be posted AS-IS in its JSON encoded form, whereas
some graph objects (usually those embedded in other graph objects as references to existing objects)
may only have their "id" or "url" posted.
*/
@property (nonatomic, assign) BOOL provisionedForPost;
@end
/*!
@class
@abstract
Static class with helpers for use with graph objects
@discussion
The public interface of this class is useful for creating objects that have the same graph characteristics
of those returned by methods of the SDK. This class also represents the internal implementation of the
`FBGraphObject` protocol, used by the Facebook SDK. Application code should not use the `FBGraphObject` class to
access instances and instance members, favoring the protocol.
*/
@interface FBGraphObject : NSMutableDictionary<FBGraphObject>
/*!
@method
@abstract
Used to create a graph object, usually for use in posting a new graph object or action.
*/
+ (NSMutableDictionary<FBGraphObject>*)graphObject;
/*!
@method
@abstract
Used to wrap an existing dictionary with a `FBGraphObject` facade
@discussion
Normally you will not need to call this method, as the Facebook SDK already "FBGraphObject-ifys" json objects
fetch via `FBRequest` and `FBRequestConnection`. However, you may have other reasons to create json objects in your
application, which you would like to treat as a graph object. The pattern for doing this is that you pass the root
node of the json to this method, to retrieve a wrapper. From this point, if you traverse the graph, any other objects
deeper in the hierarchy will be wrapped as `FBGraphObject`'s in a lazy fashion.
This method is designed to avoid unnecessary memory allocations, and object copying. Due to this, the method does
not copy the source object if it can be avoided, but rather wraps and uses it as is. The returned object derives
callers shoudl use the returned object after calls to this method, rather than continue to call methods on the original
object.
@param jsonDictionary the dictionary representing the underlying object to wrap
*/
+ (NSMutableDictionary<FBGraphObject>*)graphObjectWrappingDictionary:(NSDictionary*)jsonDictionary;
/*!
@method
@abstract
Used to create a graph object that's provisioned for POST, usually for use in posting a new Open Graph Action.
*/
+ (NSMutableDictionary<FBOpenGraphAction>*)openGraphActionForPost;
/*!
@method
@abstract
Used to create a graph object that's provisioned for POST, usually for use in posting a new Open Graph object.
*/
+ (NSMutableDictionary<FBOpenGraphObject>*)openGraphObjectForPost;
/*!
@method
@abstract
Used to create a graph object that's provisioned for POST, usually for use in posting a new Open Graph object.
@param type the object type name, in the form namespace:typename
@param title a title for the object
@param image the image property for the object
@param url the url property for the object
@param description the description for the object
*/
+ (NSMutableDictionary<FBOpenGraphObject>*)openGraphObjectForPostWithType:(NSString *)type
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description;
/*!
@method
@abstract
Used to compare two `FBGraphObject`s to determine if represent the same object. We do not overload
the concept of equality as there are various types of equality that may be important for an `FBGraphObject`
(for instance, two different `FBGraphObject`s could represent the same object, but contain different
subsets of fields).
@param anObject an `FBGraphObject` to test
@param anotherObject the `FBGraphObject` to compare it against
*/
+ (BOOL)isGraphObjectID:(id<FBGraphObject>)anObject sameAs:(id<FBGraphObject>)anotherObject;
@end

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2010-present 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 "FBGraphLocation.h"
#import "FBGraphObject.h"
/*!
@protocol
@abstract
The `FBGraphPlace` protocol enables typed access to a place object
as represented in the Graph API.
@discussion
The `FBGraphPlace` protocol represents the most commonly used properties of a
Facebook place object. It may be used to access an `NSDictionary` object that has
been wrapped with an <FBGraphObject> facade.
*/
@protocol FBGraphPlace<FBGraphObject>
/*!
@property
@abstract Typed access to the place ID.
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to the place name.
*/
@property (retain, nonatomic) NSString *name;
/*!
@property
@abstract Typed access to the place category.
*/
@property (retain, nonatomic) NSString *category;
/*!
@property
@abstract Typed access to the place location.
*/
@property (retain, nonatomic) id<FBGraphLocation> location;
@end

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
#import "FBGraphPlace.h"
/*!
@protocol
@abstract
The `FBGraphUser` protocol enables typed access to a user object
as represented in the Graph API.
@discussion
The `FBGraphUser` protocol represents the most commonly used properties of a
Facebook user object. It may be used to access an `NSDictionary` object that has
been wrapped with an <FBGraphObject> facade.
*/
@protocol FBGraphUser<FBGraphObject>
/*!
@property
@abstract Typed access to the user's ID.
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to the user's name.
*/
@property (retain, nonatomic) NSString *name;
/*!
@property
@abstract Typed access to the user's first name.
*/
@property (retain, nonatomic) NSString *first_name;
/*!
@property
@abstract Typed access to the user's middle name.
*/
@property (retain, nonatomic) NSString *middle_name;
/*!
@property
@abstract Typed access to the user's last name.
*/
@property (retain, nonatomic) NSString *last_name;
/*!
@property
@abstract Typed access to the user's profile URL.
*/
@property (retain, nonatomic) NSString *link;
/*!
@property
@abstract Typed access to the user's username.
*/
@property (retain, nonatomic) NSString *username;
/*!
@property
@abstract Typed access to the user's birthday.
*/
@property (retain, nonatomic) NSString *birthday;
/*!
@property
@abstract Typed access to the user's current city.
*/
@property (retain, nonatomic) id<FBGraphPlace> location;
@end

View File

@@ -0,0 +1,57 @@
/*
* Copyright 2010-present 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 "FBSession.h"
/*!
@typedef FBInsightsFlushBehavior enum
@abstract This enum has been deprecated in favor of FBAppEventsFlushBehavior.
*/
__attribute__ ((deprecated("use FBAppEventsFlushBehavior instead")))
typedef enum {
FBInsightsFlushBehaviorAuto __attribute__ ((deprecated("use FBAppEventsFlushBehaviorAuto instead"))),
FBInsightsFlushBehaviorExplicitOnly __attribute__ ((deprecated("use FBAppEventsFlushBehaviorExplicitOnly instead"))),
} FBInsightsFlushBehavior;
extern NSString *const FBInsightsLoggingResultNotification __attribute__((deprecated));
/*!
@class FBInsights
@abstract This class has been deprecated in favor of FBAppEvents.
*/
__attribute__ ((deprecated("Use the FBAppEvents class instead")))
@interface FBInsights : NSObject
+ (NSString *)appVersion __attribute__((deprecated));
+ (void)setAppVersion:(NSString *)appVersion __attribute__((deprecated("use [FBSettings setAppVersion] instead")));
+ (void)logPurchase:(double)purchaseAmount currency:(NSString *)currency __attribute__((deprecated("use [FBAppEvents logPurchase] instead")));
+ (void)logPurchase:(double)purchaseAmount currency:(NSString *)currency parameters:(NSDictionary *)parameters __attribute__((deprecated("use [FBAppEvents logPurchase] instead")));
+ (void)logPurchase:(double)purchaseAmount currency:(NSString *)currency parameters:(NSDictionary *)parameters session:(FBSession *)session __attribute__((deprecated("use [FBAppEvents logPurchase] instead")));
+ (void)logConversionPixel:(NSString *)pixelID valueOfPixel:(double)value __attribute__((deprecated));
+ (void)logConversionPixel:(NSString *)pixelID valueOfPixel:(double)value session:(FBSession *)session __attribute__((deprecated));
+ (FBInsightsFlushBehavior)flushBehavior __attribute__((deprecated("use [FBAppEvents flushBehavior] instead")));
+ (void)setFlushBehavior:(FBInsightsFlushBehavior)flushBehavior __attribute__((deprecated("use [FBAppEvents setFlushBehavior] instead")));
+ (void)flush __attribute__((deprecated("use [FBAppEvents flush] instead")));
@end

View File

@@ -0,0 +1,189 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
#import "FBGraphUser.h"
#import "FBSession.h"
@protocol FBLoginViewDelegate;
/*!
@class FBLoginView
@abstract FBLoginView is a custom UIView that renders a button to login or logout based on the
state of `FBSession.activeSession`
@discussion This view is closely associated with `FBSession.activeSession`. Upon initialization,
it will attempt to open an active session without UI if the current active session is not open.
The FBLoginView instance also monitors for changes to the active session.
*/
@interface FBLoginView : UIView
/*!
@abstract
The permissions to login with. Defaults to nil, meaning basic permissions.
@discussion Methods and properties that specify permissions without a read or publish
qualification are deprecated; use of a read-qualified or publish-qualified alternative is preferred.
*/
@property (readwrite, copy) NSArray *permissions __attribute__((deprecated));
/*!
@abstract
The read permissions to request if the user logs in via this view. The basic_info permission must be explicitly requested at
first login, and is no longer inferred, (subject to an active migration.)
@discussion
Note, that if read permissions are specified, then publish permissions should not be specified.
*/
@property (nonatomic, copy) NSArray *readPermissions;
/*!
@abstract
The publish permissions to request if the user logs in via this view.
@discussion
Note, that a defaultAudience value of FBSessionDefaultAudienceOnlyMe, FBSessionDefaultAudienceEveryone, or
FBSessionDefaultAudienceFriends should be set if publish permissions are specified. Additionally, when publish
permissions are specified, then read should not be specified.
*/
@property (nonatomic, copy) NSArray *publishPermissions;
/*!
@abstract
The default audience to use, if publish permissions are requested at login time.
*/
@property (nonatomic, assign) FBSessionDefaultAudience defaultAudience;
/*!
@abstract
The login behavior for the active session if the user logs in via this view
@discussion
The default value is FBSessionLoginBehaviorUseSystemAccountIfPresent.
*/
@property (nonatomic) FBSessionLoginBehavior loginBehavior;
/*!
@abstract
Initializes and returns an `FBLoginView` object. The underlying session has basic permissions granted to it.
*/
- (id)init;
/*!
@method
@abstract
Initializes and returns an `FBLoginView` object constructed with the specified permissions.
@param permissions An array of strings representing the permissions to request during the
authentication flow. A value of nil will indicates basic permissions.
@discussion Methods and properties that specify permissions without a read or publish
qualification are deprecated; use of a read-qualified or publish-qualified alternative is preferred.
*/
- (id)initWithPermissions:(NSArray *)permissions __attribute__((deprecated));
/*!
@method
@abstract
Initializes and returns an `FBLoginView` object constructed with the specified permissions.
@param readPermissions An array of strings representing the read permissions to request during the
authentication flow. A value of nil will indicates basic permissions.
*/
- (id)initWithReadPermissions:(NSArray *)readPermissions;
/*!
@method
@abstract
Initializes and returns an `FBLoginView` object constructed with the specified permissions.
@param publishPermissions An array of strings representing the publish permissions to request during the
authentication flow.
@param defaultAudience An audience for published posts; note that FBSessionDefaultAudienceNone is not valid
for permission requests that include publish or manage permissions.
*/
- (id)initWithPublishPermissions:(NSArray *)publishPermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience;
/*!
@abstract
The delegate object that receives updates for selection and display control.
*/
@property (nonatomic, assign) IBOutlet id<FBLoginViewDelegate> delegate;
@end
/*!
@protocol
@abstract
The `FBLoginViewDelegate` protocol defines the methods used to receive event
notifications from `FBLoginView` objects.
*/
@protocol FBLoginViewDelegate <NSObject>
@optional
/*!
@abstract
Tells the delegate that the view is now in logged in mode
@param loginView The login view that transitioned its view mode
*/
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView;
/*!
@abstract
Tells the delegate that the view is has now fetched user info
@param loginView The login view that transitioned its view mode
@param user The user info object describing the logged in user
*/
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user;
/*!
@abstract
Tells the delegate that the view is now in logged out mode
@param loginView The login view that transitioned its view mode
*/
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView;
/*!
@abstract
Tells the delegate that there is a communication or authorization error.
@param loginView The login view that transitioned its view mode
@param error An error object containing details of the error.
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
*/
- (void)loginView:(FBLoginView *)loginView
handleError:(NSError *)error;
@end

View File

@@ -0,0 +1,109 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "FBAppCall.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBShareDialogParams.h"
@class FBSession;
@protocol FBOpenGraphAction;
// note that the following class and types are deprecated in favor of FBDialogs and its methods
/*!
@typedef FBNativeDialogResult enum
@abstract
Please note that this enum and its related methods have been deprecated, please migrate your
code to use `FBOSIntegratedShareDialogResult` and its related methods.
*/
typedef enum {
/*! Indicates that the dialog action completed successfully. */
FBNativeDialogResultSucceeded,
/*! Indicates that the dialog action was cancelled (either by the user or the system). */
FBNativeDialogResultCancelled,
/*! Indicates that the dialog could not be shown (because not on ios6 or ios6 auth was not used). */
FBNativeDialogResultError
} FBNativeDialogResult
__attribute__((deprecated));
/*!
@typedef
@abstract
Please note that `FBShareDialogHandler` and its related methods have been deprecated, please migrate your
code to use `FBOSIntegratedShareDialogHandler` and its related methods.
*/
typedef void (^FBShareDialogHandler)(FBNativeDialogResult result, NSError *error)
__attribute__((deprecated));
/*!
@class FBNativeDialogs
@abstract
Please note that `FBNativeDialogs` has been deprecated, please migrate your
code to use `FBDialogs`.
*/
@interface FBNativeDialogs : NSObject
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `presentOSIntegratedShareDialogModallyFrom`.
*/
+ (BOOL)presentShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
image:(UIImage*)image
url:(NSURL*)url
handler:(FBShareDialogHandler)handler
__attribute__((deprecated));
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `presentOSIntegratedShareDialogModallyFrom`.
*/
+ (BOOL)presentShareDialogModallyFrom:(UIViewController*)viewController
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBShareDialogHandler)handler
__attribute__((deprecated));
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `presentOSIntegratedShareDialogModallyFrom`.
*/
+ (BOOL)presentShareDialogModallyFrom:(UIViewController*)viewController
session:(FBSession*)session
initialText:(NSString*)initialText
images:(NSArray*)images
urls:(NSArray*)urls
handler:(FBShareDialogHandler)handler
__attribute__((deprecated));
/*!
@abstract
Please note that this method has been deprecated, please migrate your
code to use `FBDialogs` and the related method `canPresentOSIntegratedShareDialogWithSession`.
*/
+ (BOOL)canPresentShareDialogWithSession:(FBSession*)session __attribute__((deprecated));
@end

View File

@@ -0,0 +1,128 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
@protocol FBGraphPlace;
@protocol FBGraphUser;
/*!
@protocol
@abstract
The `FBOpenGraphAction` protocol is the base protocol for use in posting and retrieving Open Graph actions.
It inherits from the `FBGraphObject` protocol; you may derive custome protocols from `FBOpenGraphAction` in order
implement typed access to your application's custom actions.
@discussion
Represents an Open Graph custom action, to be used directly, or from which to
derive custom action protocols with custom properties.
*/
@protocol FBOpenGraphAction<FBGraphObject>
/*!
@property
@abstract Typed access to action's id
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to action's start time
*/
@property (retain, nonatomic) NSString *start_time;
/*!
@property
@abstract Typed access to action's end time
*/
@property (retain, nonatomic) NSString *end_time;
/*!
@property
@abstract Typed access to action's publication time
*/
@property (retain, nonatomic) NSString *publish_time;
/*!
@property
@abstract Typed access to action's creation time
*/
@property (retain, nonatomic) NSString *created_time;
/*!
@property
@abstract Typed access to action's expiration time
*/
@property (retain, nonatomic) NSString *expires_time;
/*!
@property
@abstract Typed access to action's ref
*/
@property (retain, nonatomic) NSString *ref;
/*!
@property
@abstract Typed access to action's user message
*/
@property (retain, nonatomic) NSString *message;
/*!
@property
@abstract Typed access to action's place
*/
@property (retain, nonatomic) id<FBGraphPlace> place;
/*!
@property
@abstract Typed access to action's tags
*/
@property (retain, nonatomic) NSArray *tags;
/*!
@property
@abstract Typed access to action's image(s)
*/
@property (retain, nonatomic) id image;
/*!
@property
@abstract Typed access to action's from-user
*/
@property (retain, nonatomic) id<FBGraphUser> from;
/*!
@property
@abstract Typed access to action's likes
*/
@property (retain, nonatomic) NSArray *likes;
/*!
@property
@abstract Typed access to action's application
*/
@property (retain, nonatomic) id<FBGraphObject> application;
/*!
@property
@abstract Typed access to action's comments
*/
@property (retain, nonatomic) NSArray *comments;
@end

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2010-present 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 "FBDialogsParams.h"
#import "FBOpenGraphAction.h"
extern NSString *const FBPostObject;
/*!
@class FBOpenGraphActionShareDialogParams
@abstract
This object is used to encapsulate state for parameters to an Open Graph share
dialog that opens in the Facebook app.
*/
@interface FBOpenGraphActionShareDialogParams : FBDialogsParams
/*! @abstract The Open Graph action to be published. */
@property (nonatomic, retain) id<FBOpenGraphAction> action;
/*! @abstract The name of the property representing the primary target of the Open
Graph action, which will be displayed as a preview in the dialog. */
@property (nonatomic, copy) NSString *previewPropertyName;
/*! @abstract The fully qualified type of the Open Graph action. */
@property (nonatomic, copy) NSString *actionType;
@end

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2010-present 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 "FBGraphObject.h"
/*!
@protocol
@abstract
The `FBOpenGraphObject` protocol is the base protocol for use in posting and retrieving Open Graph objects.
It inherits from the `FBGraphObject` protocol; you may derive custome protocols from `FBOpenGraphObject` in order
implement typed access to your application's custom objects.
@discussion
Represents an Open Graph custom object, to be used directly, or from which to
derive custom action protocols with custom properties.
*/
@protocol FBOpenGraphObject<FBGraphObject>
/*!
@property
@abstract Typed access to the object's id
*/
@property (retain, nonatomic) NSString *id;
/*!
@property
@abstract Typed access to the object's type, which is a string in the form mynamespace:mytype
*/
@property (retain, nonatomic) NSString *type;
/*!
@property
@abstract Typed access to object's title
*/
@property (retain, nonatomic) NSString *title;
/*!
@property
@abstract Typed access to the object's image property
*/
@property (retain, nonatomic) id image;
/*!
@property
@abstract Typed access to the object's url property
*/
@property (retain, nonatomic) id url;
/*!
@property
@abstract Typed access to the object's description property
*/
@property (retain, nonatomic) id description;
/*!
@property
@abstract Typed access to action's data, which is a dictionary of custom properties
*/
@property (retain, nonatomic) id<FBGraphObject> data;
@end

View File

@@ -0,0 +1,258 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
#import "FBCacheDescriptor.h"
#import "FBGraphPlace.h"
#import "FBSession.h"
#import "FBViewController.h"
@protocol FBPlacePickerDelegate;
/*!
@class FBPlacePickerViewController
@abstract
The `FBPlacePickerViewController` class creates a controller object that manages
the user interface for displaying and selecting nearby places.
@discussion
When the `FBPlacePickerViewController` view loads it creates a `UITableView` object
where the places near a given location will be displayed. You can access this view
through the `tableView` property.
The place data can be pre-fetched and cached prior to using the view controller. The
cache is setup using an <FBCacheDescriptor> object that can trigger the
data fetch. Any place data requests will first check the cache and use that data.
If the place picker is being displayed cached data will initially be shown before
a fresh copy is retrieved.
The `delegate` property may be set to an object that conforms to the <FBPlacePickerDelegate>
protocol. The `delegate` object will receive updates related to place selection and
data changes. The delegate can also be used to filter the places to display in the
picker.
*/
@interface FBPlacePickerViewController : FBViewController
/*!
@abstract
Returns an outlet for the spinner used in the view controller.
*/
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner;
/*!
@abstract
Returns an outlet for the table view managed by the view controller.
*/
@property (nonatomic, retain) IBOutlet UITableView *tableView;
/*!
@abstract
Addtional fields to fetch when making the Graph API call to get place data.
*/
@property (nonatomic, copy) NSSet *fieldsForRequest;
/*!
@abstract
A Boolean value that indicates whether place profile pictures are displayed.
*/
@property (nonatomic) BOOL itemPicturesEnabled;
/*!
@abstract
The coordinates to use for place discovery.
*/
@property (nonatomic) CLLocationCoordinate2D locationCoordinate;
/*!
@abstract
The radius to use for place discovery.
*/
@property (nonatomic) NSInteger radiusInMeters;
/*!
@abstract
The maximum number of places to fetch.
*/
@property (nonatomic) NSInteger resultsLimit;
/*!
@abstract
The search words used to narrow down the results returned.
*/
@property (nonatomic, copy) NSString *searchText;
/*!
@abstract
The session that is used in the request for place data.
*/
@property (nonatomic, retain) FBSession *session;
/*!
@abstract
The place that is currently selected in the view. This is nil
if nothing is selected.
*/
@property (nonatomic, retain, readonly) id<FBGraphPlace> selection;
/*!
@abstract
Clears the current selection, so the picker is ready for a fresh use.
*/
- (void)clearSelection;
/*!
@abstract
Initializes a place picker view controller.
*/
- (id)init;
/*!
@abstract
Initializes a place picker view controller.
@param aDecoder An unarchiver object.
*/
- (id)initWithCoder:(NSCoder *)aDecoder;
/*!
@abstract
Initializes a place picker view controller.
@param nibNameOrNil The name of the nib file to associate with the view controller. The nib file name should not contain any leading path information. If you specify nil, the nibName property is set to nil.
@param nibBundleOrNil The bundle in which to search for the nib file. This method looks for the nib file in the bundle's language-specific project directories first, followed by the Resources directory. If nil, this method looks for the nib file in the main bundle.
*/
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
/*!
@abstract
Configures the properties used in the caching data queries.
@discussion
Cache descriptors are used to fetch and cache the data used by the view controller.
If the view controller finds a cached copy of the data, it will
first display the cached content then fetch a fresh copy from the server.
@param cacheDescriptor The <FBCacheDescriptor> containing the cache query properties.
*/
- (void)configureUsingCachedDescriptor:(FBCacheDescriptor*)cacheDescriptor;
/*!
@abstract
Initiates a query to get place data the first time or in response to changes in
the search criteria, filter, or location information.
@discussion
A cached copy will be returned if available. The cached view is temporary until a fresh copy is
retrieved from the server. It is legal to call this more than once.
*/
- (void)loadData;
/*!
@abstract
Updates the view locally without fetching data from the server or from cache.
@discussion
Use this if the filter properties change. This may affect the order or
display of information.
*/
- (void)updateView;
/*!
@method
@abstract
Creates a cache descriptor with additional fields and a profile ID for use with the
`FBPlacePickerViewController` object.
@discussion
An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
the view controller. It may also be used to configure the `FBPlacePickerViewController`
object.
@param locationCoordinate The coordinates to use for place discovery.
@param radiusInMeters The radius to use for place discovery.
@param searchText The search words used to narrow down the results returned.
@param resultsLimit The maximum number of places to fetch.
@param fieldsForRequest Addtional fields to fetch when making the Graph API call to get place data.
*/
+ (FBCacheDescriptor*)cacheDescriptorWithLocationCoordinate:(CLLocationCoordinate2D)locationCoordinate
radiusInMeters:(NSInteger)radiusInMeters
searchText:(NSString*)searchText
resultsLimit:(NSInteger)resultsLimit
fieldsForRequest:(NSSet*)fieldsForRequest;
@end
/*!
@protocol
@abstract
The `FBPlacePickerDelegate` protocol defines the methods used to receive event
notifications and allow for deeper control of the <FBPlacePickerViewController>
view.
*/
@protocol FBPlacePickerDelegate <FBViewControllerDelegate>
@optional
/*!
@abstract
Tells the delegate that data has been loaded.
@discussion
The <FBPlacePickerViewController> object's `tableView` property is automatically
reloaded when this happens. However, if another table view, for example the
`UISearchBar` is showing data, then it may also need to be reloaded.
@param placePicker The place picker view controller whose data changed.
*/
- (void)placePickerViewControllerDataDidChange:(FBPlacePickerViewController *)placePicker;
/*!
@abstract
Tells the delegate that the selection has changed.
@param placePicker The place picker view controller whose selection changed.
*/
- (void)placePickerViewControllerSelectionDidChange:(FBPlacePickerViewController *)placePicker;
/*!
@abstract
Asks the delegate whether to include a place in the list.
@discussion
This can be used to implement a search bar that filters the places list.
@param placePicker The place picker view controller that is requesting this information.
@param place An <FBGraphPlace> object representing the place.
*/
- (BOOL)placePickerViewController:(FBPlacePickerViewController *)placePicker
shouldIncludePlace:(id <FBGraphPlace>)place;
/*!
@abstract
Called if there is a communication error.
@param placePicker The place picker view controller that encountered the error.
@param error An error object containing details of the error.
*/
- (void)placePickerViewController:(FBPlacePickerViewController *)placePicker
handleError:(NSError *)error;
@end

View File

@@ -0,0 +1,80 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
/*!
@typedef FBProfilePictureCropping enum
@abstract
Type used to specify the cropping treatment of the profile picture.
@discussion
*/
typedef enum {
/*! Square (default) - the square version that the Facebook user defined. */
FBProfilePictureCroppingSquare = 0,
/*! Original - the original profile picture, as uploaded. */
FBProfilePictureCroppingOriginal = 1
} FBProfilePictureCropping;
/*!
@class
@abstract
An instance of `FBProfilePictureView` is used to display a profile picture.
The default behavior of this control is to center the profile picture
in the view and shrinks it, if necessary, to the view's bounds, preserving the aspect ratio. The smallest
possible image is downloaded to ensure that scaling up never happens. Resizing the view may result in
a different size of the image being loaded. Canonical image sizes are documented in the "Pictures" section
of https://developers.facebook.com/docs/reference/api.
*/
@interface FBProfilePictureView : UIView
/*!
@abstract
The Facebook ID of the user, place or object for which a picture should be fetched and displayed.
*/
@property (copy, nonatomic) NSString* profileID;
/*!
@abstract
The cropping to use for the profile picture.
*/
@property (nonatomic) FBProfilePictureCropping pictureCropping;
/*!
@abstract
Initializes and returns a profile view object.
*/
- (id)init;
/*!
@abstract
Initializes and returns a profile view object for the given Facebook ID and cropping.
@param profileID The Facebook ID of the user, place or object for which a picture should be fetched and displayed.
@param pictureCropping The cropping to use for the profile picture.
*/
- (id)initWithProfileID:(NSString*)profileID
pictureCropping:(FBProfilePictureCropping)pictureCropping;
@end

View File

@@ -0,0 +1,672 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "FBGraphObject.h"
#import "FBOpenGraphAction.h"
#import "FBOpenGraphObject.h"
#import "FBRequestConnection.h"
/*! The base URL used for graph requests */
extern NSString* const FBGraphBasePath __attribute__((deprecated));
// up-front decl's
@protocol FBRequestDelegate;
@class FBSession;
@class UIImage;
/*!
@typedef FBRequestState
@abstract
Deprecated - do not use in new code.
@discussion
FBRequestState is retained from earlier versions of the SDK to give existing
apps time to remove dependency on this.
@deprecated
*/
typedef NSUInteger FBRequestState __attribute__((deprecated));
/*!
@class FBRequest
@abstract
The `FBRequest` object is used to setup and manage requests to Facebook Graph
and REST APIs. This class provides helper methods that simplify the connection
and response handling.
@discussion
An <FBSession> object is required for all authenticated uses of `FBRequest`.
Requests that do not require an unauthenticated user are also supported and
do not require an <FBSession> object to be passed in.
An instance of `FBRequest` represents the arguments and setup for a connection
to Facebook. After creating an `FBRequest` object it can be used to setup a
connection to Facebook through the <FBRequestConnection> object. The
<FBRequestConnection> object is created to manage a single connection. To
cancel a connection use the instance method in the <FBRequestConnection> class.
An `FBRequest` object may be reused to issue multiple connections to Facebook.
However each <FBRequestConnection> instance will manage one connection.
Class and instance methods prefixed with **start* ** can be used to perform the
request setup and initiate the connection in a single call.
*/
@interface FBRequest : NSObject {
@private
id<FBRequestDelegate> _delegate;
NSString* _url;
NSURLConnection* _connection;
NSMutableData* _responseText;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
FBRequestState _state;
#pragma GCC diagnostic pop
NSError* _error;
BOOL _sessionDidExpire;
id<FBGraphObject> _graphObject;
}
/*!
@methodgroup Creating a request
@method
Calls <initWithSession:graphPath:parameters:HTTPMethod:> with the default parameters.
*/
- (id)init;
/*!
@method
Calls <initWithSession:graphPath:parameters:HTTPMethod:> with default parameters
except for the ones provided to this method.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
*/
- (id)initWithSession:(FBSession*)session
graphPath:(NSString *)graphPath;
/*!
@method
@abstract
Initializes an `FBRequest` object for a Graph API request call.
@discussion
Note that this only sets properties on the `FBRequest` object.
To send the request, initialize an <FBRequestConnection> object, add this request,
and send <[FBRequestConnection start]>. See other methods on this
class for shortcuts to simplify this process.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param parameters The parameters for the request. A value of nil sends only the automatically handled
parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. The default is value of nil implies a GET.
*/
- (id)initWithSession:(FBSession*)session
graphPath:(NSString *)graphPath
parameters:(NSDictionary *)parameters
HTTPMethod:(NSString *)HTTPMethod;
/*!
@method
@abstract
Initialize a `FBRequest` object that will do a graph request.
@discussion
Note that this only sets properties on the `FBRequest`.
To send the request, initialize a <FBRequestConnection>, add this request,
and send <[FBRequestConnection start]>. See other methods on this
class for shortcuts to simplify this process.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param graphObject An object or open graph action to post.
*/
- (id)initForPostWithSession:(FBSession*)session
graphPath:(NSString *)graphPath
graphObject:(id<FBGraphObject>)graphObject;
/*!
@method
@abstract
Initialize a `FBRequest` object that will do a rest API request.
@discussion
Prefer to use graph requests instead of this where possible.
Note that this only sets properties on the `FBRequest`.
To send the request, initialize a <FBRequestConnection>, add this request,
and send <[FBRequestConnection start]>. See other methods on this
class for shortcuts to simplify this process.
@param session The session object representing the identity of the Facebook user making
the request. A nil value indicates a request that requires no token; to
use the active session pass `[FBSession activeSession]`.
@param restMethod A valid REST API method.
@param parameters The parameters for the request. A value of nil sends only the automatically handled
parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. The default is value of nil implies a GET.
*/
- (id)initWithSession:(FBSession*)session
restMethod:(NSString *)restMethod
parameters:(NSDictionary *)parameters
HTTPMethod:(NSString *)HTTPMethod;
/*!
@abstract
The parameters for the request.
@discussion
May be used to read the parameters that were automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
`NSString` parameters are used to generate URL parameter values or JSON
parameters. `NSData` and `UIImage` parameters are added as attachments
to the HTTP body and referenced by name in the URL and/or JSON.
*/
@property (nonatomic, retain, readonly) NSMutableDictionary *parameters;
/*!
@abstract
The <FBSession> session object to use for the request.
@discussion
May be used to read the session that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, retain) FBSession *session;
/*!
@abstract
The Graph API endpoint to use for the request, for example "me".
@discussion
May be used to read the Graph API endpoint that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, copy) NSString *graphPath;
/*!
@abstract
A valid REST API method.
@discussion
May be used to read the REST method that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
Use the Graph API equivalent of the API if it exists as the REST API
method is deprecated if there is a Graph API equivalent.
*/
@property (nonatomic, copy) NSString *restMethod;
/*!
@abstract
The HTTPMethod to use for the request, for example "GET" or "POST".
@discussion
May be used to read the HTTP method that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, copy) NSString *HTTPMethod;
/*!
@abstract
The graph object to post with the request.
@discussion
May be used to read the graph object that was automatically set during
the object initiliazation. Make any required modifications prior to
sending the request.
*/
@property (nonatomic, retain) id<FBGraphObject> graphObject;
/*!
@methodgroup Instance methods
*/
/*!
@method
@abstract
Starts a connection to the Facebook API.
@discussion
This is used to start an API call to Facebook and call the block when the
request completes with a success, error, or cancel.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
The handler will be invoked on the main thread.
*/
- (FBRequestConnection*)startWithCompletionHandler:(FBRequestHandler)handler;
/*!
@methodgroup FBRequestConnection start methods
@abstract
These methods start an <FBRequestConnection>.
@discussion
These methods simplify the process of preparing a request and starting
the connection. The methods handle initializing an `FBRequest` object,
initializing a <FBRequestConnection> object, adding the `FBRequest`
object to the to the <FBRequestConnection>, and finally starting the
connection.
*/
/*!
@methodgroup FBRequest factory methods
@abstract
These methods initialize a `FBRequest` for common scenarios.
@discussion
These simplify the process of preparing a request to send. These
initialize a `FBRequest` based on strongly typed parameters that are
specific to the scenario.
These method do not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
*/
// request*
//
// Summary:
// Helper methods used to create common request objects which can be used to create single or batch connections
//
// session: - the session object representing the identity of the
// Facebook user making the request; nil implies an
// unauthenticated request; default=nil
/*!
@method
@abstract
Creates a request representing a Graph API call to the "me" endpoint, using the active session.
@discussion
Simplifies preparing a request to retrieve the user's identity.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
A successful Graph API call will return an <FBGraphUser> object representing the
user's identity.
Note you may change the session property after construction if a session other than
the active session is preferred.
*/
+ (FBRequest *)requestForMe;
/*!
@method
@abstract
Creates a request representing a Graph API call to the "me/friends" endpoint using the active session.
@discussion
Simplifies preparing a request to retrieve the user's friends.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
A successful Graph API call will return an array of <FBGraphUser> objects representing the
user's friends.
*/
+ (FBRequest *)requestForMyFriends;
/*!
@method
@abstract
Creates a request representing a Graph API call to upload a photo to the app's album using the active session.
@discussion
Simplifies preparing a request to post a photo.
To post a photo to a specific album, get the `FBRequest` returned from this method
call, then modify the request parameters by adding the album ID to an "album" key.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param photo A `UIImage` for the photo to upload.
*/
+ (FBRequest *)requestForUploadPhoto:(UIImage *)photo;
/*!
@method
@abstract
Creates a request representing a status update.
@discussion
Simplifies preparing a request to post a status update.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param message The message to post.
*/
+ (FBRequest *)requestForPostStatusUpdate:(NSString *)message;
/*!
@method
@abstract
Creates a request representing a status update.
@discussion
Simplifies preparing a request to post a status update.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param message The message to post.
@param place The place to checkin with, or nil. Place may be an fbid or a
graph object representing a place.
@param tags Array of friends to tag in the status update, each element
may be an fbid or a graph object representing a user.
*/
+ (FBRequest *)requestForPostStatusUpdate:(NSString *)message
place:(id)place
tags:(id<NSFastEnumeration>)tags;
/*!
@method
@abstract
Creates a request representing a Graph API call to the "search" endpoint
for a given location using the active session.
@discussion
Simplifies preparing a request to search for places near a coordinate.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
A successful Graph API call will return an array of <FBGraphPlace> objects representing
the nearby locations.
@param coordinate The search coordinates.
@param radius The search radius in meters.
@param limit The maxiumum number of results to return. It is
possible to receive fewer than this because of the radius and because of server limits.
@param searchText The text to use in the query to narrow the set of places
returned.
*/
+ (FBRequest *)requestForPlacesSearchAtCoordinate:(CLLocationCoordinate2D)coordinate
radiusInMeters:(NSInteger)radius
resultsLimit:(NSInteger)limit
searchText:(NSString*)searchText;
/*!
@method
@abstract
Creates a request representing the Graph API call to retrieve a Custom Audience "thirdy party ID" for the app's Facebook user.
Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with,
and then use the resultant Custom Audience to target ads.
@param session The FBSession to use to establish the user's identity for users logged into Facebook through this app.
If `nil`, then the activeSession is used.
@discussion
This method will throw an exception if <[FBSettings defaultAppID]> is `nil`. The appID won't be nil when the pList
includes the appID, or if it's explicitly set.
The JSON in the request's response will include an "custom_audience_third_party_id" key/value pair, with the value being the ID retrieved.
This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID.
Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior
across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
The ID retrieved represents the Facebook user identified in the following way: if the specified session (or activeSession if the specified
session is `nil`) is open, the ID will represent the user associated with the activeSession; otherwise the ID will represent the user logged into the
native Facebook app on the device. If there is no native Facebook app, no one is logged into it, or the user has opted out
at the iOS level from ad tracking, then a `nil` ID will be returned.
This method returns `nil` if either the user has opted-out (via iOS) from Ad Tracking, the app itself has limited event usage
via the `[FBAppEvents setLimitEventUsage]` flag, or a specific Facebook user cannot be identified.
*/
+ (FBRequest *)requestForCustomAudienceThirdPartyID:(FBSession *)session;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to make a Graph API call for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param graphPath The Graph API endpoint to use for the request, for example "me".
*/
+ (FBRequest *)requestForGraphPath:(NSString*)graphPath;
/*!
@method
@abstract
Creates request representing a DELETE to a object.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param object This can be an NSString, NSNumber or NSDictionary representing an object to delete
*/
+ (FBRequest *)requestForDeleteObject:(id)object;
/*!
@method
@abstract
Creates a request representing a POST for a graph object.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param graphObject An object or open graph action to post.
@discussion This method is typically used for posting an open graph action. If you are only
posting an open graph object (without an action), consider using `requestForPostOpenGraphObject:`
*/
+ (FBRequest *)requestForPostWithGraphPath:(NSString*)graphPath
graphObject:(id<FBGraphObject>)graphObject;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to make a Graph API call for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param parameters The parameters for the request. A value of nil sends only the automatically handled parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. A nil value implies a GET.
*/
+ (FBRequest *)requestWithGraphPath:(NSString*)graphPath
parameters:(NSDictionary*)parameters
HTTPMethod:(NSString*)HTTPMethod;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to create a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param object The Open Graph object to create. Some common expected fields include "title", "image", "url", etc.
*/
+ (FBRequest *)requestForPostOpenGraphObject:(id<FBOpenGraphObject>)object;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to create a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param type The fully-specified Open Graph object type (e.g., my_app_namespace:my_object_name)
@param title The title of the Open Graph object.
@param image The link to an image to be associated with the Open Graph object.
@param url The url to be associated with the Open Graph object.
@param description The description to be associated with the object.
@param objectProperties Any additional properties for the Open Graph object.
*/
+ (FBRequest *)requestForPostOpenGraphObjectWithType:(NSString *)type
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to update a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param object The Open Graph object to update the existing object with.
*/
+ (FBRequest *)requestForUpdateOpenGraphObject:(id<FBOpenGraphObject>)object;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to update a user owned
Open Graph object for the active session.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param objectId The id of the Open Graph object to update.
@param title The updated title of the Open Graph object.
@param image The updated link to an image to be associated with the Open Graph object.
@param url The updated url to be associated with the Open Graph object.
@param description The updated description of the Open Graph object.
@param objectProperties Any additional properties to update for the Open Graph object.
*/
+ (FBRequest *)requestForUpdateOpenGraphObjectWithId:(id)objectId
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties;
/*!
@method
@abstract
Returns a newly initialized request object that can be used to upload an image
to create a staging resource. Staging resources allow you to post binary data
such as images, in preparation for a post of an open graph object or action
which references the image. The URI returned when uploading a staging resource
may be passed as the image property for an open graph object or action.
@discussion
This method simplifies the preparation of a Graph API call.
This method does not initialize an <FBRequestConnection> object. To initiate the API
call first instantiate an <FBRequestConnection> object, add the request to this object,
then call the `start` method on the connection instance.
@param image A `UIImage` for the image to upload.
*/
+ (FBRequest *)requestForUploadStagingResourceWithImage:(UIImage *)image;
@end

View File

@@ -0,0 +1,626 @@
/*
* Copyright 2010-present 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 <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "FBGraphObject.h"
// up-front decl's
@class FBRequest;
@class FBRequestConnection;
@class FBSession;
@class UIImage;
/*!
@attribute beta true
@typedef FBRequestConnectionErrorBehavior enum
@abstract Describes what automatic error handling behaviors to provide (if any).
@discussion This is a bitflag enum that can be composed of different values.
See FBError.h and FBErrorUtility.h for error category and user message details.
*/
typedef enum {
/*! The default behavior of none */
FBRequestConnectionErrorBehaviorNone = 0,
/*! This will retry any requests whose error category is classified as `FBErrorCategoryRetry`.
If the retry fails, the normal handler is invoked. */
FBRequestConnectionErrorBehaviorRetry = 1,
/*! This will automatically surface any SDK provided userMessage (at most one), after
retry attempts, but before any reconnects are tried. The alert will have one button
whose text can be localized with the key "FBE:AlertMessageButton".
You should not display your own alert views in your request handler when specifying this
behavior.
*/
FBRequestConnectionErrorBehaviorAlertUser = 2,
/*! This will automatically reconnect a session if the request failed due to an invalid token
that would otherwise close the session (such as an expired token or password change). Note
this will NOT reconnect a session if the user had uninstalled the app, or if the user had
disabled the app's slider in their privacy settings (in cases of iOS 6 system auth).
If the session is reconnected, this will transition the session state to FBSessionStateTokenExtended
which will invoke any state change handlers. Otherwise, the session is closed as normal.
This behavior should not be used if the FBRequestConnection contains multiple
session instances. Further, when this behavior is used, you must not request new permissions
for the session until the connection is completed.
Lastly, you should avoid using additional FBRequestConnections with the same session because
that will be subject to race conditions.
*/
FBRequestConnectionErrorBehaviorReconnectSession = 4,
} FBRequestConnectionErrorBehavior;
/*!
Normally requests return JSON data that is parsed into a set of `NSDictionary`
and `NSArray` objects.
When a request returns a non-JSON response, that response is packaged in
a `NSDictionary` using FBNonJSONResponseProperty as the key and the literal
response as the value.
*/
extern NSString *const FBNonJSONResponseProperty;
/*!
@typedef FBRequestHandler
@abstract
A block that is passed to addRequest to register for a callback with the results of that
request once the connection completes.
@discussion
Pass a block of this type when calling addRequest. This will be called once
the request completes. The call occurs on the UI thread.
@param connection The `FBRequestConnection` that sent the request.
@param result The result of the request. This is a translation of
JSON data to `NSDictionary` and `NSArray` objects. This
is nil if there was an error.
@param error The `NSError` representing any error that occurred.
*/
typedef void (^FBRequestHandler)(FBRequestConnection *connection,
id result,
NSError *error);
/*!
@class FBRequestConnection
@abstract
The `FBRequestConnection` represents a single connection to Facebook to service a request.
@discussion
The request settings are encapsulated in a reusable <FBRequest> object. The
`FBRequestConnection` object encapsulates the concerns of a single communication
e.g. starting a connection, canceling a connection, or batching requests.
*/
@interface FBRequestConnection : NSObject
/*!
@methodgroup Creating a request
*/
/*!
@method
Calls <initWithTimeout:> with a default timeout of 180 seconds.
*/
- (id)init;
/*!
@method
@abstract
`FBRequestConnection` objects are used to issue one or more requests as a single
request/response connection with Facebook.
@discussion
For a single request, the usual method for creating an `FBRequestConnection`
object is to call one of the **start* ** methods on <FBRequest>. However, it is
allowable to init an `FBRequestConnection` object directly, and call
<addRequest:completionHandler:> to add one or more request objects to the
connection, before calling start.
Note that if requests are part of a batch, they must have an open
FBSession that has an access token associated with it. Alternatively a default App ID
must be set either in the plist or through an explicit call to <[FBSession defaultAppID]>.
@param timeout The `NSTimeInterval` (seconds) to wait for a response before giving up.
*/
- (id)initWithTimeout:(NSTimeInterval)timeout;
// properties
/*!
@abstract
The request that will be sent to the server.
@discussion
This property can be used to create a `NSURLRequest` without using
`FBRequestConnection` to send that request. It is legal to set this property
in which case the provided `NSMutableURLRequest` will be used instead. However,
the `NSMutableURLRequest` must result in an appropriate response. Furthermore, once
this property has been set, no more <FBRequest> objects can be added to this
`FBRequestConnection`.
*/
@property (nonatomic, retain, readwrite) NSMutableURLRequest *urlRequest;
/*!
@abstract
The raw response that was returned from the server. (readonly)
@discussion
This property can be used to inspect HTTP headers that were returned from
the server.
The property is nil until the request completes. If there was a response
then this property will be non-nil during the FBRequestHandler callback.
*/
@property (nonatomic, retain, readonly) NSHTTPURLResponse *urlResponse;
/*!
@attribute beta true
@abstract Set the automatic error handling behaviors.
@discussion
This must be set before any requests are added.
When using retry behaviors, note the FBRequestConnection instance
passed to the FBRequestHandler may be a different instance that the
one the requests were originally started on.
*/
@property (nonatomic, assign) FBRequestConnectionErrorBehavior errorBehavior;
/*!
@methodgroup Adding requests
*/
/*!
@method
@abstract
This method adds an <FBRequest> object to this connection.
@discussion
The completion handler is retained until the block is called upon the
completion or cancellation of the connection.
@param request A request to be included in the round-trip when start is called.
@param handler A handler to call back when the round-trip completes or times out.
The handler will be invoked on the main thread.
*/
- (void)addRequest:(FBRequest*)request
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
This method adds an <FBRequest> object to this connection.
@discussion
The completion handler is retained until the block is called upon the
completion or cancellation of the connection. This request can be named
to allow for using the request's response in a subsequent request.
@param request A request to be included in the round-trip when start is called.
@param handler A handler to call back when the round-trip completes or times out.
The handler will be invoked on the main thread.
@param name An optional name for this request. This can be used to feed
the results of one request to the input of another <FBRequest> in the same
`FBRequestConnection` as described in
[Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
*/
- (void)addRequest:(FBRequest*)request
completionHandler:(FBRequestHandler)handler
batchEntryName:(NSString*)name;
/*!
@method
@abstract
This method adds an <FBRequest> object to this connection.
@discussion
The completion handler is retained until the block is called upon the
completion or cancellation of the connection. This request can be named
to allow for using the request's response in a subsequent request.
@param request A request to be included in the round-trip when start is called.
@param handler A handler to call back when the round-trip completes or times out.
@param batchParameters The optional dictionary of parameters to include for this request
as described in [Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
Examples include "depends_on", "name", or "omit_response_on_success".
*/
- (void)addRequest:(FBRequest*)request
completionHandler:(FBRequestHandler)handler
batchParameters:(NSDictionary*)batchParameters;
/*!
@methodgroup Instance methods
*/
/*!
@method
@abstract
This method starts a connection with the server and is capable of handling all of the
requests that were added to the connection.
@discussion
Errors are reported via the handler callback, even in cases where no
communication is attempted by the implementation of `FBRequestConnection`. In
such cases multiple error conditions may apply, and if so the following
priority (highest to lowest) is used:
- `FBRequestConnectionInvalidRequestKey` -- this error is reported when an
<FBRequest> cannot be encoded for transmission.
- `FBRequestConnectionInvalidBatchKey` -- this error is reported when any
request in the connection cannot be encoded for transmission with the batch.
In this scenario all requests fail.
This method cannot be called twice for an `FBRequestConnection` instance.
*/
- (void)start;
/*!
@method
@abstract
Signals that a connection should be logically terminated as the
application is no longer interested in a response.
@discussion
Synchronously calls any handlers indicating the request was cancelled. Cancel
does not guarantee that the request-related processing will cease. It
does promise that all handlers will complete before the cancel returns. A call to
cancel prior to a start implies a cancellation of all requests associated
with the connection.
*/
- (void)cancel;
/*!
@method
@abstract
Simple method to make a graph API request for user info (/me), creates an <FBRequest>
then uses an <FBRequestConnection> object to start the connection with Facebook. The
request uses the active session represented by `[FBSession activeSession]`.
See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForMeWithCompletionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API request for user friends (/me/friends), creates an <FBRequest>
then uses an <FBRequestConnection> object to start the connection with Facebook. The
request uses the active session represented by `[FBSession activeSession]`.
See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForMyFriendsWithCompletionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API post of a photo. The request
uses the active session represented by `[FBSession activeSession]`.
@param photo A `UIImage` for the photo to upload.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForUploadPhoto:(UIImage *)photo
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API post of a status update. The request
uses the active session represented by `[FBSession activeSession]`.
@param message The message to post.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API post of a status update. The request
uses the active session represented by `[FBSession activeSession]`.
@param message The message to post.
@param place The place to checkin with, or nil. Place may be an fbid or a
graph object representing a place.
@param tags Array of friends to tag in the status update, each element
may be an fbid or a graph object representing a user.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
place:(id)place
tags:(id<NSFastEnumeration>)tags
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Starts a request representing a Graph API call to the "search" endpoint
for a given location using the active session.
@discussion
Simplifies starting a request to search for places near a coordinate.
This method creates the necessary <FBRequest> object and initializes and
starts an <FBRequestConnection> object. A successful Graph API call will
return an array of <FBGraphPlace> objects representing the nearby locations.
@param coordinate The search coordinates.
@param radius The search radius in meters.
@param limit The maxiumum number of results to return. It is
possible to receive fewer than this because of the
radius and because of server limits.
@param searchText The text to use in the query to narrow the set of places
returned.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForPlacesSearchAtCoordinate:(CLLocationCoordinate2D)coordinate
radiusInMeters:(NSInteger)radius
resultsLimit:(NSInteger)limit
searchText:(NSString*)searchText
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Starts a request representing the Graph API call to retrieve a Custom Audience "third party ID" for the app's Facebook user.
Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with,
and then use the resultant Custom Audience to target ads.
@param session The FBSession to use to establish the user's identity for users logged into Facebook through this app.
If `nil`, then the activeSession is used.
@discussion
This method will throw an exception if <[FBSettings defaultAppID]> is `nil`. The appID won't be nil when the pList
includes the appID, or if it's explicitly set.
The JSON in the request's response will include an "custom_audience_third_party_id" key/value pair, with the value being the ID retrieved.
This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID.
Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior
across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
The ID retrieved represents the Facebook user identified in the following way: if the specified session (or activeSession if the specified
session is `nil`) is open, the ID will represent the user associated with the activeSession; otherwise the ID will represent the user logged into the
native Facebook app on the device. If there is no native Facebook app, no one is logged into it, or the user has opted out
at the iOS level from ad tracking, then a `nil` ID will be returned.
This method returns `nil` if either the user has opted-out (via iOS) from Ad Tracking, the app itself has limited event usage
via the `[FBAppEvents setLimitEventUsage]` flag, or a specific Facebook user cannot be identified.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForCustomAudienceThirdPartyID:(FBSession *)session
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to make a graph API request, creates an <FBRequest> object for HTTP GET,
then uses an <FBRequestConnection> object to start the connection with Facebook. The
request uses the active session represented by `[FBSession activeSession]`.
See <connectionWithSession:graphPath:parameters:HTTPMethod:completionHandler:>
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startWithGraphPath:(NSString*)graphPath
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to delete an object using the graph API, creates an <FBRequest> object for
HTTP DELETE, then uses an <FBRequestConnection> object to start the connection with Facebook.
The request uses the active session represented by `[FBSession activeSession]`.
@param object The object to delete, may be an NSString or NSNumber representing an fbid or an NSDictionary with an id property
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForDeleteObject:(id)object
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Simple method to post an object using the graph API, creates an <FBRequest> object for
HTTP POST, then uses <FBRequestConnection> to start a connection with Facebook. The request uses
the active session represented by `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param graphObject An object or open graph action to post.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
@discussion This method is typically used for posting an open graph action. If you are only
posting an open graph object (without an action), consider using `startForPostOpenGraphObject:completionHandler:`
*/
+ (FBRequestConnection*)startForPostWithGraphPath:(NSString*)graphPath
graphObject:(id<FBGraphObject>)graphObject
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` object for a Graph API call, instantiate an
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. Use this method for
specifying the request parameters and HTTP Method. The request uses
the active session represented by `[FBSession activeSession]`.
@param graphPath The Graph API endpoint to use for the request, for example "me".
@param parameters The parameters for the request. A value of nil sends only the automatically handled parameters, for example, the access token. The default is nil.
@param HTTPMethod The HTTP method to use for the request. A nil value implies a GET.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startWithGraphPath:(NSString*)graphPath
parameters:(NSDictionary*)parameters
HTTPMethod:(NSString*)HTTPMethod
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for creating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param object The Open Graph object to create. Some common expected fields include "title", "image", "url", etc.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForPostOpenGraphObject:(id<FBOpenGraphObject>)object
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for creating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param type The fully-specified Open Graph object type (e.g., my_app_namespace:my_object_name)
@param title The title of the Open Graph object.
@param image The link to an image to be associated with the Open Graph object.
@param url The url to be associated with the Open Graph object.
@param description The description for the object.
@param objectProperties Any additional properties for the Open Graph object.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForPostOpenGraphObjectWithType:(NSString *)type
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for updating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param object The Open Graph object to update the existing object with.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection*)startForUpdateOpenGraphObject:(id<FBOpenGraphObject>)object
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Creates an `FBRequest` for updating a user owned Open Graph object, instantiate a
<FBRequestConnection> object, add the request to the newly created
connection and finally start the connection. The request uses
the active session represented by `[FBSession activeSession]`.
@param objectId The id of the Open Graph object to update.
@param title The updated title of the Open Graph object.
@param image The updated link to an image to be associated with the Open Graph object.
@param url The updated url to be associated with the Open Graph object.
@param description The object's description.
@param objectProperties Any additional properties to update for the Open Graph object.
@param handler The handler block to call when the request completes with a success, error, or cancel action.
*/
+ (FBRequestConnection *)startForUpdateOpenGraphObjectWithId:(id)objectId
title:(NSString *)title
image:(id)image
url:(id)url
description:(NSString *)description
objectProperties:(NSDictionary *)objectProperties
completionHandler:(FBRequestHandler)handler;
/*!
@method
@abstract
Starts a request connection to upload an image
to create a staging resource. Staging resources allow you to post binary data
such as images, in preparation for a post of an open graph object or action
which references the image. The URI returned when uploading a staging resource
may be passed as the value for the image property of an open graph object or action.
@discussion
This method simplifies the preparation of a Graph API call be creating the FBRequest
object and starting the request connection with a single method
@param image A `UIImage` for the image to upload.
@param handler The handler block to call when the request completes.
*/
+ (FBRequestConnection *)startForUploadStagingResourceWithImage:(UIImage *)image
completionHandler:(FBRequestHandler)handler;
@end

View File

@@ -0,0 +1,785 @@
/*
* Copyright 2010-present 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 <Accounts/Accounts.h>
#import <Foundation/Foundation.h>
// up-front decl's
@class FBAccessTokenData;
@class FBSession;
@class FBSessionTokenCachingStrategy;
#define FB_SESSIONSTATETERMINALBIT (1 << 8)
#define FB_SESSIONSTATEOPENBIT (1 << 9)
/*
* Constants used by NSNotificationCenter for active session notification
*/
/*! NSNotificationCenter name indicating that a new active session was set */
extern NSString *const FBSessionDidSetActiveSessionNotification;
/*! NSNotificationCenter name indicating that an active session was unset */
extern NSString *const FBSessionDidUnsetActiveSessionNotification;
/*! NSNotificationCenter name indicating that the active session is open */
extern NSString *const FBSessionDidBecomeOpenActiveSessionNotification;
/*! NSNotificationCenter name indicating that there is no longer an open active session */
extern NSString *const FBSessionDidBecomeClosedActiveSessionNotification;
/*!
@typedef FBSessionState enum
@abstract Passed to handler block each time a session state changes
@discussion
*/
typedef enum {
/*! One of two initial states indicating that no valid cached token was found */
FBSessionStateCreated = 0,
/*! One of two initial session states indicating that a cached token was loaded;
when a session is in this state, a call to open* will result in an open session,
without UX or app-switching*/
FBSessionStateCreatedTokenLoaded = 1,
/*! One of three pre-open session states indicating that an attempt to open the session
is underway*/
FBSessionStateCreatedOpening = 2,
/*! Open session state indicating user has logged in or a cached token is available */
FBSessionStateOpen = 1 | FB_SESSIONSTATEOPENBIT,
/*! Open session state indicating token has been extended */
FBSessionStateOpenTokenExtended = 2 | FB_SESSIONSTATEOPENBIT,
/*! Closed session state indicating that a login attempt failed */
FBSessionStateClosedLoginFailed = 1 | FB_SESSIONSTATETERMINALBIT, // NSError obj w/more info
/*! Closed session state indicating that the session was closed, but the users token
remains cached on the device for later use */
FBSessionStateClosed = 2 | FB_SESSIONSTATETERMINALBIT, // "
} FBSessionState;
/*! helper macro to test for states that imply an open session */
#define FB_ISSESSIONOPENWITHSTATE(state) (0 != (state & FB_SESSIONSTATEOPENBIT))
/*! helper macro to test for states that are terminal */
#define FB_ISSESSIONSTATETERMINAL(state) (0 != (state & FB_SESSIONSTATETERMINALBIT))
/*!
@typedef FBSessionLoginBehavior enum
@abstract
Passed to open to indicate whether Facebook Login should allow for fallback to be attempted.
@discussion
Facebook Login authorizes the application to act on behalf of the user, using the user's
Facebook account. Usually a Facebook Login will rely on an account maintained outside of
the application, by the native Facebook application, the browser, or perhaps the device
itself. This avoids the need for a user to enter their username and password directly, and
provides the most secure and lowest friction way for a user to authorize the application to
interact with Facebook. If a Facebook Login is not possible, a fallback Facebook Login may be
attempted, where the user is prompted to enter their credentials in a web-view hosted directly
by the application.
The `FBSessionLoginBehavior` enum specifies whether to allow fallback, disallow fallback, or
force fallback login behavior. Most applications will use the default, which attempts a normal
Facebook Login, and only falls back if needed. In rare cases, it may be preferable to disallow
fallback Facebook Login completely, or to force a fallback login.
*/
typedef enum {
/*! Attempt Facebook Login, ask user for credentials if necessary */
FBSessionLoginBehaviorWithFallbackToWebView = 0,
/*! Attempt Facebook Login, no direct request for credentials will be made */
FBSessionLoginBehaviorWithNoFallbackToWebView = 1,
/*! Only attempt WebView Login; ask user for credentials */
FBSessionLoginBehaviorForcingWebView = 2,
/*! Attempt Facebook Login, prefering system account and falling back to fast app switch if necessary */
FBSessionLoginBehaviorUseSystemAccountIfPresent = 3,
} FBSessionLoginBehavior;
/*!
@typedef FBSessionDefaultAudience enum
@abstract
Passed to open to indicate which default audience to use for sessions that post data to Facebook.
@discussion
Certain operations such as publishing a status or publishing a photo require an audience. When the user
grants an application permission to perform a publish operation, a default audience is selected as the
publication ceiling for the application. This enumerated value allows the application to select which
audience to ask the user to grant publish permission for.
*/
typedef enum {
/*! No audience needed; this value is useful for cases where data will only be read from Facebook */
FBSessionDefaultAudienceNone = 0,
/*! Indicates that only the user is able to see posts made by the application */
FBSessionDefaultAudienceOnlyMe = 10,
/*! Indicates that the user's friends are able to see posts made by the application */
FBSessionDefaultAudienceFriends = 20,
/*! Indicates that all Facebook users are able to see posts made by the application */
FBSessionDefaultAudienceEveryone = 30,
} FBSessionDefaultAudience;
/*!
@typedef FBSessionLoginType enum
@abstract
Used as the type of the loginType property in order to specify what underlying technology was used to
login the user.
@discussion
The FBSession object is an abstraction over five distinct mechanisms. This enum allows an application
to test for the mechanism used by a particular instance of FBSession. Usually the mechanism used for a
given login does not matter, however for certain capabilities, the type of login can impact the behavior
of other Facebook functionality.
*/
typedef enum {
/*! A login type has not yet been established */
FBSessionLoginTypeNone = 0,
/*! A system integrated account was used to log the user into the application */
FBSessionLoginTypeSystemAccount = 1,
/*! The Facebook native application was used to log the user into the application */
FBSessionLoginTypeFacebookApplication = 2,
/*! Safari was used to log the user into the application */
FBSessionLoginTypeFacebookViaSafari = 3,
/*! A web view was used to log the user into the application */
FBSessionLoginTypeWebView = 4,
/*! A test user was used to create an open session */
FBSessionLoginTypeTestUser = 5,
} FBSessionLoginType;
/*!
@typedef
@abstract Block type used to define blocks called by <FBSession> for state updates
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
Requesting additional permissions inside this handler (such as by calling
`requestNewPublishPermissions`) should be avoided because it is a poor user
experience and its behavior may vary depending on the login type. You should
request the permissions closer to the operation that requires it (e.g., when
the user performs some action).
*/
typedef void (^FBSessionStateHandler)(FBSession *session,
FBSessionState status,
NSError *error);
/*!
@typedef
@abstract Block type used to define blocks called by <[FBSession requestNewReadPermissions:completionHandler:]>
and <[FBSession requestNewPublishPermissions:defaultAudience:completionHandler:]>.
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
Requesting additional permissions inside this handler (such as by calling
`requestNewPublishPermissions`) should be avoided because it is a poor user
experience and its behavior may vary depending on the login type. You should
request the permissions closer to the operation that requires it (e.g., when
the user performs some action).
*/
typedef void (^FBSessionRequestPermissionResultHandler)(FBSession *session,
NSError *error);
/*!
@typedef
@abstract Block type used to define blocks called by <[FBSession reauthorizeWithPermissions]>.
@discussion You should use the preferred FBSessionRequestPermissionHandler typedef rather than
this synonym, which has been deprecated.
*/
typedef FBSessionRequestPermissionResultHandler FBSessionReauthorizeResultHandler __attribute__((deprecated));
/*!
@typedef
@abstract Block type used to define blocks called for system credential renewals.
@discussion
*/
typedef void (^FBSessionRenewSystemCredentialsHandler)(ACAccountCredentialRenewResult result, NSError *error) ;
/*!
@class FBSession
@abstract
The `FBSession` object is used to authenticate a user and manage the user's session. After
initializing a `FBSession` object the Facebook App ID and desired permissions are stored.
Opening the session will initiate the authentication flow after which a valid user session
should be available and subsequently cached. Closing the session can optionally clear the
cache.
If an <FBRequest> request requires user authorization then an `FBSession` object should be used.
@discussion
Instances of the `FBSession` class provide notification of state changes in the following ways:
1. Callers of certain `FBSession` methods may provide a block that will be called
back in the course of state transitions for the session (e.g. login or session closed).
2. The object supports Key-Value Observing (KVO) for property changes.
*/
@interface FBSession : NSObject
/*!
@methodgroup Creating a session
*/
/*!
@method
@abstract
Returns a newly initialized Facebook session with default values for the parameters
to <initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:>.
*/
- (id)init;
/*!
@method
@abstract
Returns a newly initialized Facebook session with the specified permissions and other
default values for parameters to <initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:>.
@param permissions An array of strings representing the permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no
longer inferred, (subject to an active migration.) The default is nil.
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
or publish permissions only; not both. The permissions passed here should reflect this requirement.
*/
- (id)initWithPermissions:(NSArray*)permissions;
/*!
@method
@abstract
Following are the descriptions of the arguments along with their
defaults when ommitted.
@param permissions An array of strings representing the permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer inferred, (subject to an active migration.) The default is nil.
@param appID The Facebook App ID for the session. If nil is passed in the default App ID will be obtained from a call to <[FBSession defaultAppID]>. The default is nil.
@param urlSchemeSuffix The URL Scheme Suffix to be used in scenarious where multiple iOS apps use one Facebook App ID. A value of nil indicates that this information should be pulled from [FBSettings defaultUrlSchemeSuffix]. The default is nil.
@param tokenCachingStrategy Specifies a key name to use for cached token information in NSUserDefaults, nil
indicates a default value of @"FBAccessTokenInformationKey".
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
or publish permissions only; not both. The permissions passed here should reflect this requirement.
*/
- (id)initWithAppID:(NSString*)appID
permissions:(NSArray*)permissions
urlSchemeSuffix:(NSString*)urlSchemeSuffix
tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy;
/*!
@method
@abstract
Following are the descriptions of the arguments along with their
defaults when ommitted.
@param permissions An array of strings representing the permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer inferred, (subject to an active migration.) The default is nil.
@param defaultAudience Most applications use FBSessionDefaultAudienceNone here, only specifying an audience when using reauthorize to request publish permissions.
@param appID The Facebook App ID for the session. If nil is passed in the default App ID will be obtained from a call to <[FBSession defaultAppID]>. The default is nil.
@param urlSchemeSuffix The URL Scheme Suffix to be used in scenarious where multiple iOS apps use one Facebook App ID. A value of nil indicates that this information should be pulled from [FBSettings defaultUrlSchemeSuffix]. The default is nil.
@param tokenCachingStrategy Specifies a key name to use for cached token information in NSUserDefaults, nil
indicates a default value of @"FBAccessTokenInformationKey".
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
or publish permissions only; not both. The permissions passed here should reflect this requirement. If publish permissions
are used, then the audience must also be specified.
*/
- (id)initWithAppID:(NSString*)appID
permissions:(NSArray*)permissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
urlSchemeSuffix:(NSString*)urlSchemeSuffix
tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy;
// instance readonly properties
/*! @abstract Indicates whether the session is open and ready for use. */
@property (readonly) BOOL isOpen;
/*! @abstract Detailed session state */
@property (readonly) FBSessionState state;
/*! @abstract Identifies the Facebook app which the session object represents. */
@property (readonly, copy) NSString *appID;
/*! @abstract Identifies the URL Scheme Suffix used by the session. This is used when multiple iOS apps share a single Facebook app ID. */
@property (readonly, copy) NSString *urlSchemeSuffix;
/*! @abstract The access token for the session object.
@discussion Deprecated. Use the `accessTokenData` property. */
@property(readonly, copy) NSString *accessToken
__attribute__((deprecated));
/*! @abstract The expiration date of the access token for the session object.
@discussion Deprecated. Use the `accessTokenData` property. */
@property(readonly, copy) NSDate *expirationDate
__attribute__((deprecated));
/*! @abstract The permissions granted to the access token during the authentication flow. */
@property (readonly, copy) NSArray *permissions;
/*! @abstract Specifies the login type used to authenticate the user.
@discussion Deprecated. Use the `accessTokenData` property. */
@property(readonly) FBSessionLoginType loginType
__attribute__((deprecated));
/*! @abstract Gets the FBAccessTokenData for the session */
@property (readonly, copy) FBAccessTokenData *accessTokenData;
/*!
@methodgroup Instance methods
*/
/*!
@method
@abstract Opens a session for the Facebook.
@discussion
A session may not be used with <FBRequest> and other classes in the SDK until it is open. If, prior
to calling open, the session is in the <FBSessionStateCreatedTokenLoaded> state, then no UX occurs, and
the session becomes available for use. If the session is in the <FBSessionStateCreated> state, prior
to calling open, then a call to open causes login UX to occur, either via the Facebook application
or via mobile Safari.
Open may be called at most once and must be called after the `FBSession` is initialized. Open must
be called before the session is closed. Calling an open method at an invalid time will result in
an exception. The open session methods may be passed a block that will be called back when the session
state changes. The block will be released when the session is closed.
@param handler A block to call with the state changes. The default is nil.
*/
- (void)openWithCompletionHandler:(FBSessionStateHandler)handler;
/*!
@method
@abstract Logs a user on to Facebook.
@discussion
A session may not be used with <FBRequest> and other classes in the SDK until it is open. If, prior
to calling open, the session is in the <FBSessionStateCreatedTokenLoaded> state, then no UX occurs, and
the session becomes available for use. If the session is in the <FBSessionStateCreated> state, prior
to calling open, then a call to open causes login UX to occur, either via the Facebook application
or via mobile Safari.
The method may be called at most once and must be called after the `FBSession` is initialized. It must
be called before the session is closed. Calling the method at an invalid time will result in
an exception. The open session methods may be passed a block that will be called back when the session
state changes. The block will be released when the session is closed.
@param behavior Controls whether to allow, force, or prohibit Facebook Login or Inline Facebook Login. The default
is to allow Facebook Login, with fallback to Inline Facebook Login.
@param handler A block to call with session state changes. The default is nil.
*/
- (void)openWithBehavior:(FBSessionLoginBehavior)behavior
completionHandler:(FBSessionStateHandler)handler;
/*!
@method
@abstract Imports an existing access token and opens the session with it.
@discussion
The method attempts to open the session using an existing access token. No UX will occur. If
successful, the session with be in an Open state and the method will return YES; otherwise, NO.
The method may be called at most once and must be called after the `FBSession` is initialized (see below).
It must be called before the session is closed. Calling the method at an invalid time will result in
an exception. The open session methods may be passed a block that will be called back when the session
state changes. The block will be released when the session is closed.
The initialized session must not have already been initialized from a cache (for example, you could use
the `[FBSessionTokenCachingStrategy nullCacheInstance]` instance).
@param accessTokenData The token data. See `FBAccessTokenData` for construction methods.
@param handler A block to call with session state changes. The default is nil.
*/
- (BOOL)openFromAccessTokenData:(FBAccessTokenData *)accessTokenData completionHandler:(FBSessionStateHandler) handler;
/*!
@abstract
Closes the local in-memory session object, but does not clear the persisted token cache.
*/
- (void)close;
/*!
@abstract
Closes the in-memory session, and clears any persisted cache related to the session.
*/
- (void)closeAndClearTokenInformation;
/*!
@abstract
Reauthorizes the session, with additional permissions.
@param permissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions. The default is nil.
@param behavior Controls whether to allow, force, or prohibit Facebook Login. The default
is to allow Facebook Login and fall back to Inline Facebook Login if needed.
@param handler A block to call with session state changes. The default is nil.
@discussion Methods and properties that specify permissions without a read or publish
qualification are deprecated; use of a read-qualified or publish-qualified alternative is preferred
(e.g. reauthorizeWithReadPermissions or reauthorizeWithPublishPermissions)
*/
- (void)reauthorizeWithPermissions:(NSArray*)permissions
behavior:(FBSessionLoginBehavior)behavior
completionHandler:(FBSessionReauthorizeResultHandler)handler
__attribute__((deprecated));
/*!
@abstract
Reauthorizes the session, with additional permissions.
@param readPermissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions.
@param handler A block to call with session state changes. The default is nil.
@discussion This method is a deprecated alias of <[FBSession requestNewReadPermissions:completionHandler:]>. Consider
using <[FBSession requestNewReadPermissions:completionHandler:]>, which is preferred for readability.
*/
- (void)reauthorizeWithReadPermissions:(NSArray*)readPermissions
completionHandler:(FBSessionReauthorizeResultHandler)handler
__attribute__((deprecated));
/*!
@abstract
Reauthorizes the session, with additional permissions.
@param writePermissions An array of strings representing the permissions to request during the
authentication flow.
@param defaultAudience Specifies the audience for posts.
@param handler A block to call with session state changes. The default is nil.
@discussion This method is a deprecated alias of <[FBSession requestNewPublishPermissions:defaultAudience:completionHandler:]>.
Consider using <[FBSession requestNewPublishPermissions:defaultAudience:completionHandler:]>, which is preferred for readability.
*/
- (void)reauthorizeWithPublishPermissions:(NSArray*)writePermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
completionHandler:(FBSessionReauthorizeResultHandler)handler
__attribute__((deprecated));
/*!
@abstract
Requests new or additional read permissions for the session.
@param readPermissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions.
@param handler A block to call with session state changes. The default is nil.
@discussion The handler, if non-nil, is called once the operation has completed or failed. This is in contrast to the
state completion handler used in <[FBSession openWithCompletionHandler:]> (and other `open*` methods) which is called
for each state-change for the session.
*/
- (void)requestNewReadPermissions:(NSArray*)readPermissions
completionHandler:(FBSessionRequestPermissionResultHandler)handler;
/*!
@abstract
Requests new or additional write permissions for the session.
@param writePermissions An array of strings representing the permissions to request during the
authentication flow.
@param defaultAudience Specifies the audience for posts.
@param handler A block to call with session state changes. The default is nil.
@discussion The handler, if non-nil, is called once the operation has completed or failed. This is in contrast to the
state completion handler used in <[FBSession openWithCompletionHandler:]> (and other `open*` methods) which is called
for each state-change for the session.
*/
- (void)requestNewPublishPermissions:(NSArray*)writePermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
completionHandler:(FBSessionRequestPermissionResultHandler)handler;
/*!
@abstract
A helper method that is used to provide an implementation for
[UIApplicationDelegate application:openURL:sourceApplication:annotation:]. It should be invoked during
the Facebook Login flow and will update the session information based on the incoming URL.
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
*/
- (BOOL)handleOpenURL:(NSURL*)url;
/*!
@abstract
A helper method that is used to provide an implementation for
[UIApplicationDelegate applicationDidBecomeActive:] to properly resolve session state for
the Facebook Login flow, specifically to support app-switch login.
*/
- (void)handleDidBecomeActive;
/*!
@abstract
Assign the block to be invoked for session state changes.
@discussion
This will overwrite any state change handler that was already assigned. Typically,
you should only use this setter if you were unable to assign a state change handler explicitly.
One example of this is if you are not opening the session (e.g., using the `open*`)
but still want to assign a `FBSessionStateHandler` block. This can happen when the SDK
opens a session from an app link.
*/
- (void)setStateChangeHandler:(FBSessionStateHandler)stateChangeHandler;
/*!
@methodgroup Class methods
*/
/*!
@abstract
This is the simplest method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
Note, if there is not a cached token available, this method will present UI to the user in order to
open the session via explicit login by the user.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be disirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@discussion
Returns YES if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
*/
+ (BOOL)openActiveSessionWithAllowLoginUI:(BOOL)allowLoginUI;
/*!
@abstract
This is a simple method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
@param permissions An array of strings representing the permissions to request during the
authentication flow. A value of nil indicates basic permissions. A nil value specifies
default permissions.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be desirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@param handler Many applications will benefit from notification when a session becomes invalid
or undergoes other state transitions. If a block is provided, the FBSession
object will call the block each time the session changes state.
@discussion
Returns true if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
It is required that initial permissions requests represent read-only permissions only. If publish
permissions are needed, you may use reauthorizeWithPermissions to specify additional permissions as
well as an audience. Use of this method will result in a legacy fast-app-switch Facebook Login due to
the requirement to separate read and publish permissions for newer applications. Methods and properties
that specify permissions without a read or publish qualification are deprecated; use of a read-qualified
or publish-qualified alternative is preferred.
*/
+ (BOOL)openActiveSessionWithPermissions:(NSArray*)permissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler
__attribute__((deprecated));
/*!
@abstract
This is a simple method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
@param readPermissions An array of strings representing the read permissions to request during the
authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer
inferred, (subject to an active migration.) It is not allowed to pass publish permissions to this method.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be desirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@param handler Many applications will benefit from notification when a session becomes invalid
or undergoes other state transitions. If a block is provided, the FBSession
object will call the block each time the session changes state.
@discussion
Returns true if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
*/
+ (BOOL)openActiveSessionWithReadPermissions:(NSArray*)readPermissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
/*!
@abstract
This is a simple method for opening a session with Facebook. Using sessionOpen logs on a user,
and sets the static activeSession which becomes the default session object for any Facebook UI widgets
used by the application. This session becomes the active session, whether open succeeds or fails.
@param publishPermissions An array of strings representing the publish permissions to request during the
authentication flow.
@param defaultAudience Anytime an app publishes on behalf of a user, the post must have an audience (e.g. me, my friends, etc.)
The default audience is used to notify the user of the cieling that the user agrees to grant to the app for the provided permissions.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
be desirable to transition to login UI for the user, and yet an open session is desired so long as a cached
token can be used to open the session. Passing NO to this argument, assures the method will not present UI
to the user in order to open the session.
@param handler Many applications will benefit from notification when a session becomes invalid
or undergoes other state transitions. If a block is provided, the FBSession
object will call the block each time the session changes state.
@discussion
Returns true if the session was opened synchronously without presenting UI to the user. This occurs
when there is a cached token available from a previous run of the application. If NO is returned, this indicates
that the session was not immediately opened, via cache. However, if YES was passed as allowLoginUI, then it is
possible that the user will login, and the session will become open asynchronously. The primary use for
this return value is to switch-on facebook capabilities in your UX upon startup, in the case where the session
is opened via cache.
*/
+ (BOOL)openActiveSessionWithPublishPermissions:(NSArray*)publishPermissions
defaultAudience:(FBSessionDefaultAudience)defaultAudience
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
/*!
@abstract
An application may get or set the current active session. Certain high-level components in the SDK
will use the activeSession to set default session (e.g. `FBLoginView`, `FBFriendPickerViewController`)
@discussion
If sessionOpen* is called, the resulting `FBSession` object also becomes the activeSession. If another
session was active at the time, it is closed automatically. If activeSession is called when no session
is active, a session object is instatiated and returned; in this case open must be called on the session
in order for it to be useable for communication with Facebook.
*/
+ (FBSession*)activeSession;
/*!
@abstract
An application may get or set the current active session. Certain high-level components in the SDK
will use the activeSession to set default session (e.g. `FBLoginView`, `FBFriendPickerViewController`)
@param session The FBSession object to become the active session
@discussion
If an application prefers the flexibilility of directly instantiating a session object, an active
session can be set directly.
*/
+ (FBSession*)setActiveSession:(FBSession*)session;
/*!
@method
@abstract Set the default Facebook App ID to use for sessions. The app ID may be
overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings setDefaultAppID].
@param appID The default Facebook App ID to use for <FBSession> methods.
*/
+ (void)setDefaultAppID:(NSString*)appID __attribute__((deprecated));
/*!
@method
@abstract Get the default Facebook App ID to use for sessions. If not explicitly
set, the default will be read from the application's plist. The app ID may be
overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings defaultAppID].
*/
+ (NSString*)defaultAppID __attribute__((deprecated));
/*!
@method
@abstract Set the default url scheme suffix to use for sessions. The url
scheme suffix may be overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings setDefaultUrlSchemeSuffix].
@param urlSchemeSuffix The default url scheme suffix to use for <FBSession> methods.
*/
+ (void)setDefaultUrlSchemeSuffix:(NSString*)urlSchemeSuffix __attribute__((deprecated));
/*!
@method
@abstract Get the default url scheme suffix used for sessions. If not
explicitly set, the default will be read from the application's plist. The
url scheme suffix may be overridden on a per session basis.
@discussion This method has been deprecated in favor of [FBSettings defaultUrlSchemeSuffix].
*/
+ (NSString*)defaultUrlSchemeSuffix __attribute__((deprecated));
/*!
@method
@abstract Issues an asychronous renewCredentialsForAccount call to the device Facebook account store.
@param handler The completion handler to call when the renewal is completed. The handler will be
invoked on the main thread.
@discussion This can be used to explicitly renew account credentials on iOS 6 devices and is provided
as a convenience wrapper around `[ACAccountStore renewCredentialsForAccount:completion]`. Note the
method will not issue the renewal call if the the Facebook account has not been set on the device, or
if access had not been granted to the account (though the handler wil receive an error).
This is safe to call (and will surface an error to the handler) on versions of iOS before 6 or if the user
logged in via Safari or Facebook SSO.
*/
+ (void)renewSystemCredentials:(FBSessionRenewSystemCredentialsHandler)handler;
@end

View File

@@ -0,0 +1,160 @@
/*
* Copyright 2010-present 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 "FBAccessTokenData.h"
/*!
@class
@abstract
The `FBSessionTokenCachingStrategy` class is responsible for persisting and retrieving cached data related to
an <FBSession> object, including the user's Facebook access token.
@discussion
`FBSessionTokenCachingStrategy` is designed to be instantiated directly or used as a base class. Usually default
token caching behavior is sufficient, and you do not need to interface directly with `FBSessionTokenCachingStrategy` objects.
However, if you need to control where or how `FBSession` information is cached, then you may take one of two approaches.
The first and simplest approach is to instantiate an instance of `FBSessionTokenCachingStrategy`, and then pass
the instance to `FBSession` class' `init` method. This enables your application to control the key name used in
`NSUserDefaults` to store session information. You may consider this approach if you plan to cache session information
for multiple users.
The second and more advanced approached is to derive a custom class from `FBSessionTokenCachingStrategy`, which will
be responsible for caching behavior of your application. This approach is useful if you need to change where the
information is cached, for example if you prefer to use the filesystem or make a network connection to fetch and
persist cached tokens. Inheritors should override the cacheTokenInformation, fetchTokenInformation, and clearToken methods.
Doing this enables your application to implement any token caching scheme, including no caching at all (see
`[FBSessionTokenCachingStrategy* nullCacheInstance ]`.
Direct use of `FBSessionTokenCachingStrategy`is an advanced technique. Most applications use <FBSession> objects without
passing an `FBSessionTokenCachingStrategy`, which yields default caching to `NSUserDefaults`.
*/
@interface FBSessionTokenCachingStrategy : NSObject
/*!
@abstract Initializes and returns an instance
*/
- (id)init;
/*!
@abstract
Initializes and returns an instance
@param tokenInformationKeyName Specifies a key name to use for cached token information in NSUserDefaults, nil
indicates a default value of @"FBAccessTokenInformationKey"
*/
- (id)initWithUserDefaultTokenInformationKeyName:(NSString*)tokenInformationKeyName;
/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order to cache token information.
@param tokenInformation Dictionary containing token information to be cached by the method
@discussion You should favor overriding this instead of `cacheFBAccessTokenData` only if you intend
to cache additional data not captured by the FBAccessTokenData type.
*/
- (void)cacheTokenInformation:(NSDictionary*)tokenInformation;
/*!
@abstract Cache the supplied token.
@param accessToken The token instance.
@discussion This essentially wraps a call to `cacheTokenInformation` so you should
override this when providing a custom token caching strategy.
*/
- (void)cacheFBAccessTokenData:(FBAccessTokenData *)accessToken;
/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order to fetch cached token information
@discussion
An overriding implementation should only return a token if it
can also return an expiration date, otherwise return nil.
You should favor overriding this instead of `fetchFBAccessTokenData` only if you intend
to cache additional data not captured by the FBAccessTokenData type.
*/
- (NSDictionary*)fetchTokenInformation;
/*!
@abstract
Fetches the cached token instance.
@discussion
This essentially wraps a call to `fetchTokenInformation` so you should
override this when providing a custom token caching strategy.
In order for an `FBSession` instance to be able to use a cached token,
the token must be not be expired (see `+isValidTokenInformation:`) and
must also contain all permissions in the initialized session instance.
*/
- (FBAccessTokenData *)fetchFBAccessTokenData;
/*!
@abstract
Called by <FBSession> (and overridden by inheritors), in order delete any cached information for the current token
*/
- (void)clearToken;
/*!
@abstract
Helper function called by the SDK as well as apps, in order to fetch the default strategy instance.
*/
+ (FBSessionTokenCachingStrategy*)defaultInstance;
/*!
@abstract
Helper function to return a FBSessionTokenCachingStrategy instance that does not perform any caching.
*/
+ (FBSessionTokenCachingStrategy*)nullCacheInstance;
/*!
@abstract
Helper function called by the SDK as well as application code, used to determine whether a given dictionary
contains the minimum token information usable by the <FBSession>.
@param tokenInformation Dictionary containing token information to be validated
*/
+ (BOOL)isValidTokenInformation:(NSDictionary*)tokenInformation;
@end
// The key to use with token information dictionaries to get and set the token value
extern NSString *const FBTokenInformationTokenKey;
// The to use with token information dictionaries to get and set the expiration date
extern NSString *const FBTokenInformationExpirationDateKey;
// The to use with token information dictionaries to get and set the refresh date
extern NSString *const FBTokenInformationRefreshDateKey;
// The key to use with token information dictionaries to get the related user's fbid
extern NSString *const FBTokenInformationUserFBIDKey;
// The key to use with token information dictionaries to determine whether the token was fetched via Facebook Login
extern NSString *const FBTokenInformationIsFacebookLoginKey;
// The key to use with token information dictionaries to determine whether the token was fetched via the OS
extern NSString *const FBTokenInformationLoginTypeLoginKey;
// The key to use with token information dictionaries to get the latest known permissions
extern NSString *const FBTokenInformationPermissionsKey;
// The key to use with token information dictionaries to get the date the permissions were last refreshed.
extern NSString *const FBTokenInformationPermissionsRefreshDateKey;

View File

@@ -0,0 +1,327 @@
/*
* Copyright 2010-present 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 <CoreGraphics/CGBase.h>
/*
* Constants defining logging behavior. Use with <[FBSettings setLoggingBehavior]>.
*/
/*! Log requests from FBRequest* classes */
extern NSString *const FBLoggingBehaviorFBRequests;
/*! Log requests from FBURLConnection* classes */
extern NSString *const FBLoggingBehaviorFBURLConnections;
/*! Include access token in logging. */
extern NSString *const FBLoggingBehaviorAccessTokens;
/*! Log session state transitions. */
extern NSString *const FBLoggingBehaviorSessionStateTransitions;
/*! Log performance characteristics */
extern NSString *const FBLoggingBehaviorPerformanceCharacteristics;
/*! Log FBAppEvents interactions */
extern NSString *const FBLoggingBehaviorAppEvents;
/*! Log Informational occurrences */
extern NSString *const FBLoggingBehaviorInformational;
/*! Log errors likely to be preventable by the developer. This is in the default set of enabled logging behaviors. */
extern NSString *const FBLoggingBehaviorDeveloperErrors;
@class FBGraphObject;
/*!
@typedef
@abstract Block type used to get install data that is returned by server when publishInstall is called
@discussion
*/
typedef void (^FBInstallResponseDataHandler)(FBGraphObject *response, NSError *error);
/*!
@typedef
@abstract A list of beta features that can be enabled for the SDK. Beta features are for evaluation only,
and are therefore only enabled for DEBUG builds. Beta features should not be enabled
in release builds.
*/
typedef enum : NSUInteger {
FBBetaFeaturesNone = 0,
#if defined(DEBUG) || defined(FB_BUILD_ONLY)
FBBetaFeaturesShareDialog = 1 << 0,
FBBetaFeaturesOpenGraphShareDialog = 1 << 1,
#endif
} FBBetaFeatures;
/*!
@typedef
@abstract Indicates if this app should be restricted
*/
typedef NS_ENUM(NSUInteger, FBRestrictedTreatment) {
/*! The default treatment indicating the app is not restricted. */
FBRestrictedTreatmentNO = 0,
/*! Indicates the app is restricted. */
FBRestrictedTreatmentYES = 1
};
@interface FBSettings : NSObject
/*!
@method
@abstract Retrieve the current iOS SDK version.
*/
+ (NSString *)sdkVersion;
/*!
@method
@abstract Retrieve the current Facebook SDK logging behavior.
*/
+ (NSSet *)loggingBehavior;
/*!
@method
@abstract Set the current Facebook SDK logging behavior. This should consist of strings defined as
constants with FBLogBehavior*, and can be constructed with, e.g., [NSSet initWithObjects:].
@param loggingBehavior A set of strings indicating what information should be logged. If nil is provided, the logging
behavior is reset to the default set of enabled behaviors. Set in an empty set in order to disable all logging.
*/
+ (void)setLoggingBehavior:(NSSet *)loggingBehavior;
/*! @abstract deprecated method */
+ (BOOL)shouldAutoPublishInstall __attribute__ ((deprecated));
/*! @abstract deprecated method */
+ (void)setShouldAutoPublishInstall:(BOOL)autoPublishInstall __attribute__ ((deprecated));
/*!
@method
@abstract This method has been replaced by [FBAppEvents activateApp] */
+ (void)publishInstall:(NSString *)appID __attribute__ ((deprecated("use [FBAppEvents activateApp] instead")));
/*!
@method
@abstract Manually publish an attributed install to the Facebook graph, and return the server response back in
the supplied handler. Calling this method will implicitly turn off auto-publish. This method acquires the
current attribution id from the facebook application, queries the graph API to determine if the application
has install attribution enabled, publishes the id, and records success to avoid reporting more than once.
@param appID A specific appID to publish an install for. If nil, uses [FBSession defaultAppID].
@param handler A block to call with the server's response.
*/
+ (void)publishInstall:(NSString *)appID
withHandler:(FBInstallResponseDataHandler)handler __attribute__ ((deprecated));
/*!
@method
@abstract
Gets the application version to the provided string. `FBAppEvents`, for instance, attaches the app version to
events that it logs, which are then available in App Insights.
*/
+ (NSString *)appVersion;
/*!
@method
@abstract
Sets the application version to the provided string. `FBAppEvents`, for instance, attaches the app version to
events that it logs, which are then available in App Insights.
@param appVersion The version identifier of the iOS app.
*/
+ (void)setAppVersion:(NSString *)appVersion;
/*!
@method
@abstract Retrieve the Client Token that has been set via [FBSettings setClientToken]
*/
+ (NSString *)clientToken;
/*!
@method
@abstract Sets the Client Token for the Facebook App. This is needed for certain API calls when made anonymously,
without a user-based Session.
@param clientToken The Facebook App's "client token", which, for a given appid can be found in the Security
section of the Advanced tab of the Facebook App settings found at <https://developers.facebook.com/apps/[your-app-id]>
*/
+ (void)setClientToken:(NSString *)clientToken;
/*!
@method
@abstract Set the default Facebook Display Name to be used by the SDK. This should match
the Display Name that has been set for the app with the corresponding Facebook App ID, in
the Facebook App Dashboard
@param displayName The default Facebook Display Name to be used by the SDK.
*/
+ (void)setDefaultDisplayName:(NSString *)displayName;
/*!
@method
@abstract Get the default Facebook Display Name used by the SDK. If not explicitly
set, the default will be read from the application's plist.
*/
+ (NSString *)defaultDisplayName;
/*!
@method
@abstract Set the default Facebook App ID to use for sessions. The SDK allows the appID
to be overridden per instance in certain cases (e.g. per instance of FBSession)
@param appID The default Facebook App ID to be used by the SDK.
*/
+ (void)setDefaultAppID:(NSString*)appID;
/*!
@method
@abstract Get the default Facebook App ID used by the SDK. If not explicitly
set, the default will be read from the application's plist. The SDK allows the appID
to be overridden per instance in certain cases (e.g. per instance of FBSession)
*/
+ (NSString*)defaultAppID;
/*!
@method
@abstract Set the default url scheme suffix used by the SDK.
@param urlSchemeSuffix The default url scheme suffix to be used by the SDK.
*/
+ (void)setDefaultUrlSchemeSuffix:(NSString*)urlSchemeSuffix;
/*!
@method
@abstract Get the default url scheme suffix used for sessions. If not
explicitly set, the default will be read from the application's plist value for 'FacebookUrlSchemeSuffix'.
*/
+ (NSString*)defaultUrlSchemeSuffix;
/*!
@method
@abstract Set the bundle name from the SDK will try and load overrides of images and text
@param bundleName The name of the bundle (MyFBBundle).
*/
+ (void)setResourceBundleName:(NSString*)bundleName;
/*!
@method
@abstract Get the name of the bundle to override the SDK images and text
*/
+ (NSString*)resourceBundleName;
/*!
@method
@abstract Set the subpart of the facebook domain (e.g. @"beta") so that requests will be sent to graph.beta.facebook.com
@param facebookDomainPart The domain part to be inserted into facebook.com
*/
+ (void)setFacebookDomainPart:(NSString*)facebookDomainPart;
/*!
@method
@abstract Get the Facebook domain part
*/
+ (NSString*)facebookDomainPart;
/*!
@method
@abstract Enables the specified beta features. Beta features are for evaluation only,
and are therefore only enabled for debug builds. Beta features should not be enabled
in release builds.
@param betaFeatures The beta features to enable (expects a bitwise OR of FBBetaFeatures)
*/
+ (void)enableBetaFeatures:(NSUInteger)betaFeatures;
/*!
@method
@abstract Enables a beta feature. Beta features are for evaluation only,
and are therefore only enabled for debug builds. Beta features should not be enabled
in release builds.
@param betaFeature The beta feature to enable.
*/
+ (void)enableBetaFeature:(FBBetaFeatures)betaFeature;
/*!
@method
@abstract Disables a beta feature.
@param betaFeature The beta feature to disable.
*/
+ (void)disableBetaFeature:(FBBetaFeatures)betaFeature;
/*!
@method
@abstract Determines whether a beta feature is enabled or not.
@param betaFeature The beta feature to check.
@return YES if the beta feature is enabled, NO if not.
*/
+ (BOOL)isBetaFeatureEnabled:(FBBetaFeatures)betaFeature;
/*!
@method
@abstract
Gets whether data such as that generated through FBAppEvents and sent to Facebook should be restricted from being used for other than analytics and conversions. Defaults to NO. This value is stored on the device and persists across app launches.
*/
+ (BOOL)limitEventAndDataUsage;
/*!
@method
@abstract
Sets whether data such as that generated through FBAppEvents and sent to Facebook should be restricted from being used for other than analytics and conversions. Defaults to NO. This value is stored on the device and persists across app launches.
@param limitEventAndDataUsage The desired value.
*/
+ (void)setLimitEventAndDataUsage:(BOOL)limitEventAndDataUsage;
@end

View File

@@ -0,0 +1,67 @@
/*
* Copyright 2010-present 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 "FBDialogsParams.h"
/*!
@class FBShareDialogParams
@abstract
This object is used to encapsulate state for parameters to a share dialog that
opens in the Facebook app.
*/
@interface FBShareDialogParams : FBDialogsParams
/*! @abstract The URL link to be attached to the post. Only "http" or "https"
schemes are supported. */
@property (nonatomic, copy) NSURL *link;
/*! @abstract The name, or title associated with the link. Is only used if the
link is non-nil. */
@property (nonatomic, copy) NSString *name;
/*! @abstract The caption to be used with the link. Is only used if the link is
non-nil. */
@property (nonatomic, copy) NSString *caption;
/*! @abstract The description associated with the link. Is only used if the
link is non-nil. */
@property (nonatomic, copy) NSString *description;
/*! @abstract The link to a thumbnail to associate with the post. Is only used
if the link is non-nil. Only "http" or "https" schemes are supported.*/
@property (nonatomic, copy) NSURL *picture;
/*! @abstract An array of NSStrings or FBGraphUsers to tag in the post.
If using NSStrings, the values must represent the IDs of the users to tag. */
@property (nonatomic, copy) NSArray *friends;
/*! @abstract An NSString or FBGraphPlace to tag in the status update. If
NSString, the value must be the ID of the place to tag. */
@property (nonatomic, copy) id place;
/*! @abstract A text reference for the category of the post, used on Facebook
Insights. */
@property (nonatomic, copy) NSString *ref;
/*! @abstract If YES, treats any data failures (e.g. failures when getting
data for IDs passed through "friends" or "place") as a fatal error, and will not
continue with the status update. */
@property (nonatomic, assign) BOOL dataFailuresFatal;
@end

View File

@@ -0,0 +1,138 @@
/*
* Copyright 2010-present 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 "FBSession.h"
#if defined (DEBUG)
#define SAFE_TO_USE_FBTESTSESSION
#endif
#if !defined(SAFE_TO_USE_FBTESTSESSION)
#pragma message ("warning: using FBTestSession, which is designed for unit-testing uses only, in non-DEBUG code -- ensure this is what you really want")
#endif
/*!
Consider using this tag to pass to sessionWithSharedUserWithPermissions:uniqueUserTag: when
you need a second unique test user in a test case. Using the same tag each time reduces
the proliferation of test users.
*/
extern NSString *kSecondTestUserTag;
/*!
Consider using this tag to pass to sessionWithSharedUserWithPermissions:uniqueUserTag: when
you need a third unique test user in a test case. Using the same tag each time reduces
the proliferation of test users.
*/
extern NSString *kThirdTestUserTag;
/*!
@class FBTestSession
@abstract
Implements an FBSession subclass that knows about test users for a particular
application. This should never be used from a real application, but may be useful
for writing unit tests, etc.
@discussion
Facebook allows developers to create test accounts for testing their applications'
Facebook integration (see https://developers.facebook.com/docs/test_users/). This class
simplifies use of these accounts for writing unit tests. It is not designed for use in
production application code.
The main use case for this class is using sessionForUnitTestingWithPermissions:mode:
to create a session for a test user. Two modes are supported. In "shared" mode, an attempt
is made to find an existing test user that has the required permissions and, if it is not
currently in use by another FBTestSession, just use that user. If no such user is available,
a new one is created with the required permissions. In "private" mode, designed for
scenarios which require a new user in a known clean state, a new test user will always be
created, and it will be automatically deleted when the FBTestSession is closed.
Note that the shared test user functionality depends on a naming convention for the test users.
It is important that any testing of functionality which will mutate the permissions for a
test user NOT use a shared test user, or this scheme will break down. If a shared test user
seems to be in an invalid state, it can be deleted manually via the Web interface at
https://developers.facebook.com/apps/APP_ID/permissions?role=test+users.
*/
@interface FBTestSession : FBSession
/// The app access token (composed of app ID and secret) to use for accessing test users.
@property (readonly, copy) NSString *appAccessToken;
/// The ID of the test user associated with this session.
@property (readonly, copy) NSString *testUserID;
/// The App ID of the test app as configured in the plist.
@property (readonly, copy) NSString *testAppID;
/// The App Secret of the test app as configured in the plist.
@property (readonly, copy) NSString *testAppSecret;
// Defaults to NO. If set to YES, reauthorize calls will fail with a nil token
// as if the user had cancelled it reauthorize.
@property (assign) BOOL disableReauthorize;
/*!
@abstract
Constructor helper to create a session for use in unit tests
@discussion
This method creates a session object which uses a shared test user with the right permissions,
creating one if necessary on open (but not deleting it on close, so it can be re-used in later
tests). Calling this method multiple times may return sessions with the same user. If this is not
desired, use the variant sessionWithSharedUserWithPermissions:uniqueUserTag:.
This method should not be used in application code -- but is useful for creating unit tests
that use the Facebook SDK.
@param permissions array of strings naming permissions to authorize; nil indicates
a common default set of permissions should be used for unit testing
*/
+ (id)sessionWithSharedUserWithPermissions:(NSArray*)permissions;
/*!
@abstract
Constructor helper to create a session for use in unit tests
@discussion
This method creates a session object which uses a shared test user with the right permissions,
creating one if necessary on open (but not deleting it on close, so it can be re-used in later
tests).
This method should not be used in application code -- but is useful for creating unit tests
that use the Facebook SDK.
@param permissions array of strings naming permissions to authorize; nil indicates
a common default set of permissions should be used for unit testing
@param uniqueUserTag a string which will be used to make this user unique among other
users with the same permissions. Useful for tests which require two or more users to interact
with each other, and which therefore must have sessions associated with different users. For
this case, consider using kSecondTestUserTag and kThirdTestUserTag so these users can be shared
with other, similar, tests.
*/
+ (id)sessionWithSharedUserWithPermissions:(NSArray*)permissions
uniqueUserTag:(NSString*)uniqueUserTag;
/*!
@abstract
Constructor helper to create a session for use in unit tests
@discussion
This method creates a session object which creates a test user on open, and destroys the user on
close; This method should not be used in application code -- but is useful for creating unit tests
that use the Facebook SDK.
@param permissions array of strings naming permissions to authorize; nil indicates
a common default set of permissions should be used for unit testing
*/
+ (id)sessionWithPrivateUserWithPermissions:(NSArray*)permissions;
@end

View File

@@ -0,0 +1,128 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
#import "FBSession.h"
#import "FBViewController.h"
/*!
@protocol
@abstract
The `FBUserSettingsDelegate` protocol defines the methods called by a <FBUserSettingsViewController>.
*/
@protocol FBUserSettingsDelegate <FBViewControllerDelegate>
@optional
/*!
@abstract
Called when the view controller will log the user out in response to a button press.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerWillLogUserOut:(id)sender;
/*!
@abstract
Called after the view controller logged the user out in response to a button press.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerDidLogUserOut:(id)sender;
/*!
@abstract
Called when the view controller will log the user in in response to a button press.
Note that logging in can fail for a number of reasons, so there is no guarantee that this
will be followed by a call to loginViewControllerDidLogUserIn:. Callers wanting more granular
notification of the session state changes can use KVO or the NSNotificationCenter to observe them.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerWillAttemptToLogUserIn:(id)sender;
/*!
@abstract
Called after the view controller successfully logged the user in in response to a button press.
@param sender The view controller sending the message.
*/
- (void)loginViewControllerDidLogUserIn:(id)sender;
/*!
@abstract
Called if the view controller encounters an error while trying to log a user in.
@param sender The view controller sending the message.
@param error The error encountered.
@discussion See https://developers.facebook.com/docs/technical-guides/iossdk/errors/
for error handling best practices.
*/
- (void)loginViewController:(id)sender receivedError:(NSError *)error;
@end
/*!
@class FBUserSettingsViewController
@abstract
The `FBUserSettingsViewController` class provides a user interface exposing a user's
Facebook-related settings. Currently, this is limited to whether they are logged in or out
of Facebook.
Because of the size of some graphics used in this view, its resources are packaged as a separate
bundle. In order to use `FBUserSettingsViewController`, drag the `FBUserSettingsViewResources.bundle`
from the SDK directory into your Xcode project.
*/
@interface FBUserSettingsViewController : FBViewController
/*!
@abstract
The permissions to request if the user logs in via this view.
*/
@property (nonatomic, copy) NSArray *permissions __attribute__((deprecated));
/*!
@abstract
The read permissions to request if the user logs in via this view.
@discussion
Note, that if read permissions are specified, then publish permissions should not be specified.
*/
@property (nonatomic, copy) NSArray *readPermissions;
/*!
@abstract
The publish permissions to request if the user logs in via this view.
@discussion
Note, that a defaultAudience value of FBSessionDefaultAudienceOnlyMe, FBSessionDefaultAudienceEveryone, or
FBSessionDefaultAudienceFriends should be set if publish permissions are specified. Additionally, when publish
permissions are specified, then read should not be specified.
*/
@property (nonatomic, copy) NSArray *publishPermissions;
/*!
@abstract
The default audience to use, if publish permissions are requested at login time.
*/
@property (nonatomic, assign) FBSessionDefaultAudience defaultAudience;
@end

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
@class FBViewController;
/*!
@typedef FBModalCompletionHandler
@abstract
A block that is passed to [FBViewController presentModallyInViewController:animated:handler:]
and called when the view controller is dismissed via either Done or Cancel.
@param sender The <FBViewController> that is being dismissed.
@param donePressed If YES, Done was pressed. If NO, Cancel was pressed.
*/
typedef void (^FBModalCompletionHandler)(FBViewController *sender, BOOL donePressed);
/*!
@protocol
@abstract
The `FBViewControllerDelegate` protocol defines the methods called when the Cancel or Done
buttons are pressed in a <FBViewController>.
*/
@protocol FBViewControllerDelegate <NSObject>
@optional
/*!
@abstract
Called when the Cancel button is pressed on a modally-presented <FBViewController>.
@param sender The view controller sending the message.
*/
- (void)facebookViewControllerCancelWasPressed:(id)sender;
/*!
@abstract
Called when the Done button is pressed on a modally-presented <FBViewController>.
@param sender The view controller sending the message.
*/
- (void)facebookViewControllerDoneWasPressed:(id)sender;
@end
/*!
@class FBViewController
@abstract
The `FBViewController` class is a base class encapsulating functionality common to several
other view controller classes. Specifically, it provides UI when a view controller is presented
modally, in the form of optional Cancel and Done buttons.
*/
@interface FBViewController : UIViewController
/*!
@abstract
The Cancel button to display when presented modally. If nil, no Cancel button is displayed.
If this button is provided, its target and action will be redirected to internal handlers, replacing
any previous target that may have been set.
*/
@property (nonatomic, retain) IBOutlet UIBarButtonItem *cancelButton;
/*!
@abstract
The Done button to display when presented modally. If nil, no Done button is displayed.
If this button is provided, its target and action will be redirected to internal handlers, replacing
any previous target that may have been set.
*/
@property (nonatomic, retain) IBOutlet UIBarButtonItem *doneButton;
/*!
@abstract
The delegate that will be called when Cancel or Done is pressed. Derived classes may specify
derived types for their delegates that provide additional functionality.
*/
@property (nonatomic, assign) IBOutlet id<FBViewControllerDelegate> delegate;
/*!
@abstract
The view into which derived classes should put their subviews. This view will be resized correctly
depending on whether or not a toolbar is displayed.
*/
@property (nonatomic, readonly, retain) UIView *canvasView;
/*!
@abstract
Provides a wrapper that presents the view controller modally and automatically dismisses it
when either the Done or Cancel button is pressed.
@param viewController The view controller that is presenting this view controller.
@param animated If YES, presenting and dismissing the view controller is animated.
@param handler The block called when the Done or Cancel button is pressed.
*/
- (void)presentModallyFromViewController:(UIViewController*)viewController
animated:(BOOL)animated
handler:(FBModalCompletionHandler)handler;
@end

View File

@@ -0,0 +1,234 @@
/*
* Copyright 2010-present 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 <UIKit/UIKit.h>
@class FBFrictionlessRecipientCache;
@class FBSession;
@protocol FBWebDialogsDelegate;
/*!
@typedef FBWebDialogResult enum
@abstract
Passed to a handler to indicate the result of a dialog being displayed to the user.
*/
typedef enum {
/*! Indicates that the dialog action completed successfully. Note, that cancel operations represent completed dialog operations.
The url argument may be used to distinguish between success and user-cancelled cases */
FBWebDialogResultDialogCompleted,
/*! Indicates that the dialog operation was not completed. This occurs in cases such as the closure of the web-view using the X in the upper left corner. */
FBWebDialogResultDialogNotCompleted
} FBWebDialogResult;
/*!
@typedef
@abstract Defines a handler that will be called in response to the web dialog
being dismissed
*/
typedef void (^FBWebDialogHandler)(
FBWebDialogResult result,
NSURL *resultURL,
NSError *error);
/*!
@class FBWebDialogs
@abstract
Provides methods to display web based dialogs to the user.
*/
@interface FBWebDialogs : NSObject
/*!
@abstract
Presents a Facebook web dialog (https://developers.facebook.com/docs/reference/dialogs/ )
such as feed or apprequest.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present, or returns NO, if not.
@param dialog Represents the dialog or method name, such as @"feed"
@param parameters A dictionary of parameters to be passed to the dialog
@param handler An optional handler that will be called when the dialog is dismissed. Note,
that if the method returns NO, the handler is not called. May be nil.
*/
+ (void)presentDialogModallyWithSession:(FBSession *)session
dialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler;
/*!
@abstract
Presents a Facebook web dialog (https://developers.facebook.com/docs/reference/dialogs/ )
such as feed or apprequest.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present, or returns NO, if not.
@param dialog Represents the dialog or method name, such as @"feed"
@param parameters A dictionary of parameters to be passed to the dialog
@param handler An optional handler that will be called when the dialog is dismissed. Note,
that if the method returns NO, the handler is not called. May be nil.
@param delegate An optional delegate to allow for advanced processing of web based
dialogs. See 'FBWebDialogsDelegate' for more details.
*/
+ (void)presentDialogModallyWithSession:(FBSession *)session
dialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler
delegate:(id<FBWebDialogsDelegate>)delegate;
/*!
@abstract
Presents a Facebook apprequest dialog.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present.
@param message The required message for the dialog.
@param title An optional title for the dialog.
@param parameters A dictionary of additional parameters to be passed to the dialog. May be nil
@param handler An optional handler that will be called when the dialog is dismissed. May be nil.
*/
+ (void)presentRequestsDialogModallyWithSession:(FBSession *)session
message:(NSString *)message
title:(NSString *)title
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler;
/*!
@abstract
Presents a Facebook apprequest dialog.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present.
@param message The required message for the dialog.
@param title An optional title for the dialog.
@param parameters A dictionary of additional parameters to be passed to the dialog. May be nil
@param handler An optional handler that will be called when the dialog is dismissed. May be nil.
@param friendCache An optional cache object used to enable frictionless sharing for a known set of friends. The
cache instance should be preserved for the life of the session and reused for multiple calls to the present method.
As the users set of friends enabled for frictionless sharing changes, this method auto-updates the cache.
*/
+ (void)presentRequestsDialogModallyWithSession:(FBSession *)session
message:(NSString *)message
title:(NSString *)title
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler
friendCache:(FBFrictionlessRecipientCache *)friendCache;
/*!
@abstract
Presents a Facebook feed dialog.
@param session Represents the session to use for the dialog. May be nil, which uses
the active session if present.
@param parameters A dictionary of additional parameters to be passed to the dialog. May be nil
@param handler An optional handler that will be called when the dialog is dismissed. May be nil.
*/
+ (void)presentFeedDialogModallyWithSession:(FBSession *)session
parameters:(NSDictionary *)parameters
handler:(FBWebDialogHandler)handler;
@end
/*!
@protocol
@abstract
The `FBWebDialogsDelegate` protocol enables the plugging of advanced behaviors into
the presentation flow of a Facebook web dialog. Advanced uses include modification
of parameters and application-level handling of links on the dialog. The
`FBFrictionlessRequestFriendCache` class implements this protocol to add frictionless
behaviors to a presentation of the request dialog.
*/
@protocol FBWebDialogsDelegate<NSObject>
@optional
/*!
@abstract
Called prior to the presentation of a web dialog
@param dialog A string representing the method or dialog name of the dialog being presented.
@param parameters A mutable dictionary of parameters which will be sent to the dialog.
@param session The session object to use with the dialog.
*/
- (void)webDialogsWillPresentDialog:(NSString *)dialog
parameters:(NSMutableDictionary *)parameters
session:(FBSession *)session;
/*!
@abstract
Called when the user of a dialog clicks a link that would cause a transition away from the application.
Your application may handle this method, and return NO if the URL handling will be performed by the application.
@param dialog A string representing the method or dialog name of the dialog being presented.
@param parameters A dictionary of parameters which were sent to the dialog.
@param session The session object to use with the dialog.
@param url The url in question, which will not be handled by the SDK if this method NO
*/
- (BOOL)webDialogsDialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
session:(FBSession *)session
shouldAutoHandleURL:(NSURL *)url;
/*!
@abstract
Called when the dialog is about to be dismissed
@param dialog A string representing the method or dialog name of the dialog being presented.
@param parameters A dictionary of parameters which were sent to the dialog.
@param session The session object to use with the dialog.
@param result A pointer to a result, which may be read or changed by the handling method as needed
@param url A pointer to a pointer to a URL representing the URL returned by the dialog, which may be read or changed by this mehthod
@param error A pointer to a pointer to an error object which may be read or changed by this method as needed
*/
- (void)webDialogsWillDismissDialog:(NSString *)dialog
parameters:(NSDictionary *)parameters
session:(FBSession *)session
result:(FBWebDialogResult *)result
url:(NSURL **)url
error:(NSError **)error;
@end

View File

@@ -0,0 +1,139 @@
/*
* Copyright 2010-present 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.
*/
// core
#import "FBAccessTokenData.h"
#import "FBAppCall.h"
#import "FBAppEvents.h"
#import "FBCacheDescriptor.h"
#import "FBDialogs.h"
#import "FBError.h"
#import "FBErrorUtility.h"
#import "FBFrictionlessRecipientCache.h"
#import "FBFriendPickerViewController.h"
#import "FBGraphLocation.h"
#import "FBGraphObject.h" // + design summary for graph component-group
#import "FBGraphPlace.h"
#import "FBGraphUser.h"
#import "FBInsights.h"
#import "FBLoginView.h"
#import "FBNativeDialogs.h" // deprecated, use FBDialogs.h
#import "FBOpenGraphAction.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBOpenGraphObject.h"
#import "FBPlacePickerViewController.h"
#import "FBProfilePictureView.h"
#import "FBRequest.h"
#import "FBSession.h"
#import "FBSessionTokenCachingStrategy.h"
#import "FBSettings.h"
#import "FBShareDialogParams.h"
#import "FBUserSettingsViewController.h"
#import "FBWebDialogs.h"
#import "NSError+FBError.h"
/*!
@header
@abstract Library header, import this to import all of the public types
in the Facebook SDK
@discussion
////////////////////////////////////////////////////////////////////////////////
Summary: this header summarizes the structure and goals of the Facebook SDK for iOS.
Goals:
* Leverage and work well with modern features of iOS (e.g. blocks, ARC, etc.)
* Patterned after best of breed iOS frameworks (e.g. naming, pattern-use, etc.)
* Common integration experience is simple & easy to describe
* Factored to enable a growing list of scenarios over time
Notes on approaches:
1. We use a key scenario to drive prioritization of work for a given update
2. We are building-atop and refactoring, rather than replacing, existing iOS SDK releases
3. We use take an incremental approach where we can choose to maintain as little or as much compatibility with the existing SDK needed
a) and so we will be developing to this approach
b) and then at push-time for a release we will decide when/what to break
on a feature by feature basis
4. Some light but critical infrastructure is needed to support both the goals
and the execution of this change (e.g. a build/package/deploy process)
Design points:
We will move to a more object-oriented approach, in order to facilitate the
addition of a different class of objects, such as controls and visual helpers
(e.g. FBLikeView, FBPersonView), as well as sub-frameworks to enable scenarios
such (e.g. FBOpenGraphEntity, FBLocalEntityCache, etc.)
As we add features, it will no longer be appropriate to host all functionality
in the Facebook class, though it will be maintained for some time for migration
purposes. Instead functionality lives in related collections of classes.
<pre>
@textblock
*------------* *----------* *----------------* *---*
Scenario --> |FBPersonView| |FBLikeView| | FBPlacePicker | | F |
*------------* *----------* *----------------* | a |
*-------------------* *----------* *--------* | c |
Component --> | FBGraphObject | | FBDialog | | FBView | | e |
*-------------------* *----------* *--------* | b |
*---------* *---------* *---------------------* | o |
Core --> |FBSession| |FBRequest| |Utilities (e.g. JSON)| | o |
*---------* *---------* *---------------------* * k *
@/textblock
</pre>
The figure above describes three layers of functionality, with the existing
Facebook on the side as a helper proxy to a subset of the overall SDK. The
layers loosely organize the SDK into *Core Objects* necessary to interface
with Facebook, higher-level *Framework Components* that feel like natural
extensions to existing frameworks such as UIKit and Foundation, but which
surface behavior broadly applicable to Facebook, and finally the
*Scenario Objects*, which provide deeper turn-key capibilities for useful
mobile scenarios.
Use example (low barrier use case):
<pre>
@textblock
// log on to Facebook
[FBSession sessionOpenWithPermissions:nil
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
if (session.isOpen) {
// request basic information for the user
[FBRequestConnection startWithGraphPath:@"me"
completionHandler:^void(FBRequestConnection *request,
id result,
NSError *error) {
if (!error) {
// get json from result
}
}];
}
}];
@/textblock
</pre>
*/
#define FB_IOS_SDK_VERSION_STRING @"3.11.1"

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2010-present 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 "FBError.h"
/*!
@category NSError(FBError)
@abstract
Adds additional properties to NSError to provide more information for Facebook related errors.
*/
@interface NSError (FBError)
/*!
@abstract
Categorizes the error, if it is Facebook related, to simplify application mitigation behavior
@discussion
In general, in response to an error connecting to Facebook, an application should, retry the
operation, request permissions, reconnect the application, or prompt the user to take an action.
The error category can be used to understand the class of error received from Facebook. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
*/
@property (readonly) FBErrorCategory fberrorCategory;
/*!
@abstract
If YES indicates that a user action is required in order to successfully continue with the facebook operation
@discussion
In general if fberrorShouldNotifyUser is NO, then the application has a straightforward mitigation, such as
retry the operation or request permissions from the user, etc. In some cases it is necessary for the user to
take an action before the application continues to attempt a Facebook connection. For more infomation on this
see https://developers.facebook.com/docs/reference/api/errors/
*/
@property (readonly) BOOL fberrorShouldNotifyUser;
/*!
@abstract
A message suitable for display to the user, describing a user action necessary to enable Facebook functionality.
Not all Facebook errors yield a message suitable for user display; however in all cases where
fberrorShouldNotifyUser is YES, this property returns a localizable message suitable for display.
*/
@property (readonly, copy) NSString *fberrorUserMessage;
@end

Some files were not shown because too many files have changed in this diff Show More