Core ModulesObjective C
MediaFireSDK Object
MediaFireSDK
This is the main MediaFire API access object. It must be initialized first by using createWithConfig:.
Also, you must supply your own appID, and if necessary, your own API Key.
The appID and API Key needed are created when registering as a developer.
Once initialized, a login attempt can be made with startSession:withPassword:andCallbacks: or startFacebookSession:withCallbacks. If credentials have already been stored and validated, use startSession:withCallbacks. If you don't need to override the default behaviors of the SDK, then almost everything you will need can be done through the MediaFireSDK shared instance.
Class Methods
+ createWithConfig:
Initializes the shared instance with given configuration.+ (bool)createWithConfig:(NSDictionary*)config;Parameters
- config : Dictionary containing app-specific configuration. Expects @"app_id" to be a non-nil NSString. See MFConfig for a list of valid keys.
+ getInstance
Returns the MediaFireSDK shared instance.+ (instancetype)getInstance;
+ startSession:withPassword:andCallbacks:
Establishes a session with the MediaFire API via email and password combination.+ (void)startSession:(NSString*)email withPassword:(NSString*)password andCallbacks:(NSDictionary*)callbacks;Parameters
- email : The user's email address.
- password : The user's password.
- callbacks : A dictionary containing an onload callback and onerror callback. See NSDictionary(Callbacks).
+ startSessionWithCallbacks:
Established a session with the MediaFire API via stored credentials.+ (void)startSessionWithCallbacks:(NSDictionary*)callbacks;Parameters
- callbacks : A dictionary containing an onload callback and onerror callback. See NSDictionary(Callbacks).
+ startFacebookSession:withCallbacks:
Establishes a session with the MediaFire API via facebook token.+ (void)startFacebookSession:(NSString*)authToken withCallbacks:(NSDictionary*)callbacks;Parameters
- authToken : The user's Facebook token, supplied by Facebook after a successful authentication thru facebook.com.
- callbacks : A dictionary containing an onload callback and onerror callback. See NSDictionary(Callbacks).
+ endSession
Purges all existing session tokens, disabling any further requests.+ (void)endSession;
+ hasSession
Returns true if 1 or more session tokens are available.+ (BOOL)hasSession;
+ destroy
Destroys the MediaFireSDK shared instance.+ (void)destroy;
+ SessionAPI
Returns the MediaFireSDK singleton's stored instance of the MFSessionAPI class.+ (MFSessionAPI*)SessionAPI;
+ ActionTokenAPI
Returns the MediaFireSDK singleton's stored instance of the MFActionTokenAPI class.+ (MFActionTokenAPI*)ActionTokenAPI;
+ ContactAPI
Returns the MediaFireSDK singleton's stored instance of the MFConctactAPI class.+ (MFContactAPI*)ContactAPI;
+ DeviceAPI
Returns the MediaFireSDK singleton's stored instance of the MFDeviceAPI class.+ (MFDeviceAPI*)DeviceAPI;
+ FileAPI
Returns the MediaFireSDK singleton's stored instance of the MFFileAPI class.+ (MFFileAPI*)FileAPI;
+ FolderAPI
Returns the MediaFireSDK singleton's stored instance of the MFFolderAPI class.+ (MFFolderAPI*)FolderAPI;
+ SystemAPI
Returns the MediaFireSDK singleton's stored instance of the MFSystemAPI class.+ (MFSystemAPI*)SystemAPI;
+ UploadAPI
Returns the MediaFireSDK singleton's stored instance of the MFUploadAPI class.+ (MFUploadAPI*)UploadAPI;
+ UserAPI
Returns the MediaFireSDK singleton's stored instance of the MFUserAPI class.+ (MFUserAPI*)UserAPI;
+ MediaAPI
Returns the MediaFireSDK singleton's stored instance of the MFMediaAPI class.+ (MFMediaAPI*)MediaAPI;
MFConfig
This is the global configuration interface for the MediaFireSDK. It is initialized with an NSDictionary. The only required keys are appID and if your app requires it, API Key.
The appID and API Key needed are created when registering as a developer.
If you are using the MediaFireSDK shared instance, the dictionary you pass to it in createWithConfig: is passed directly to MFConfig for initialization.
Constants
- MFCONF_APPID : The name of the "app id" property in an MFConfig dictionary.
- MFCONF_APIKEY : The name of the "api key" property in an MFConfig dictionary.
- MFCONF_CREDS_DELEGATE : The name of the "credentials delegate" property in an MFConfig dictionary.
- MFCONF_PRM_DELEGATE : The name of the "parallel request manager delegate" property in an MFConfig dictionary.
- MFCONF_SRM_DELEGATE : The name of the "serial request manager delegate" property in an MFConfig dictionary.
- MFCONF_MINTOKEN : The name of the "minimum tokens" property in an MFConfig dictionary.
- MFCONF_MAXTOKEN : The name of the "maximum tokens" property in an MFConfig dictionary.
- MFCONF_NETIND_DELEGATE : The name of the "network indicator delegate" property in an MFConfig dictionary.
- MFCONF_HTTPCLIENT : The name of the "http client configuration" property in an MFConfig dictionary.
Properties
- appId : The application ID.
- apiKey : The application's API key. Depending on the app settings in the MediaFire developer portal, this value may be optional.
- maxTokens : The maximum number of session tokens for the Serial Request Manager to reserve.
- minTokens : The minimum number of session tokens for the Serial Request Manager to reserve.
Class Methods
+ createWithConfig:
Initializes the shared instance with given configuration.+ (void)createWithConfig:(NSDictionary*)config;Parameters
- config :Dictionary containing app-specific configuration.
+ instance
Returns the MFConfig shared instance.+ (MFConfig*)instance;
+ destroy
Destroys the MFConfig shared instance.+ (void)destroy;
+ credentialsDelegate
Returns the class of the currently registered credentials delegate.+ (Class)credentialsDelegate;
+ parallelRequestDelegate
Returns the class of the currently registered Parallel Request Manager delegate.+ (Class)parallelRequestDelegate;
+ serialRequestDelegate
Returns the class of the currently registered Serial Request Manager delegate.+ (Class)serialRequestDelegate;
+ defaultAPIVersion
Returns the defaul API version that this version of the SDK defaults to.+ (NSString*)defaultAPIVersion;
+ registerHTTPClient:withId:
Stores a reference by name (clientId) that subsequent API requests can be directed thru using the 'options' dictionary.+ (BOOL)registerHTTPClient:(id)client withId:(NSString*)clientId;Parameters
- client : An initialized object that conforms to the MFHTTPClientDelegate protocol.
- clientId : A unique name for the supplied client that can be used in API requests to route them thru the supplied client.
+ unregisterHTTPClient:
Removes reference to the named client, and calls the client's 'destroy' delegate method.+ (BOOL)unregisterHTTPClient:(NSString*)clientId;Parameters
- clientId : The unique name of the client.
+ httpClientById:
Resturns the client identified by the unique name in clientId.+ (id)httpClientById:(NSString*)clientId;Parameters
- clientId : The client's unique name.
+ showNetworkIndicator
Calls 'showNetworkIndicator' on the Network Indicator Delegate if one was supplied to MFConfig in createWithConfig:.+ (void)showNetworkIndicator;
+ hideNetworkIndicator
Calls 'hideNetworkIndicator' on the Network Indicator Delegate if one was supplied to MFConfig in createWithConfig:.+ (void)hideNetworkIndicator;
+ defaultHttpClient
Returns the SDK's default http client. If no http client config was supplied to MFConfig in createWithConfig: then this function will return [NSURLSession sharedSession].+ (NSURLSession*)defaultHttpClient;
Callbacks
NSDictionary
This is the standard container for callbacks used throughout the MediaFire SDK. Nearly all asynchronous functions in the SDK will expect an object of this type for callbacks. You should always provide at least ONLOAD and ONERROR. For upload requests, you should also provide ONPROGRESS.
Constants
- ONLOAD : The dictionary key for a success callback.
- ONERROR : The dictionary key for an error callback.
- ONPROGRESS : The dictionary key for a progress callback.
- ONUPDATE : The dictionary key for an upate callback.
Properties
- onload : A success callback.
- onerror : An error callback.
- onprogress : A progress callback. Intended for rapid calls, for file transfer progress indication.
- onupdate : An update callback. Similar to onprogress but uses the MFCallback style, not intended for rapid calls. Used as an alternative to NSNotification.