IOS Access Guide
SDK includes a class ( MPShareSDK) and a protocol (MPSDKProtocol), mainly including the following several methods:
@protocol MPSDKProtocol <NSObject> @optional /** * Whether it’s successful to share to Meipai * * @param success */ - (void) shareToMeipaiDidSuccess:(BOOL) success; @end @interface MPShareSDK : NSObject /** * Register and apply to Meipai * * @param appKey Appkey registered */ + (void) registerApp:(NSString *) appKey; /** * Install Meipai or not */ + (BOOL) isMeipaiInstalled; /** * Whether current Meipai support video sharing from the third party */ + (BOOL) isMeipaiSupportSharing; /** * Handle Meipai client program and start the data passed of third party applicationby url * It needs to call in application:openURL:sourceApplication:annotation: or application:handleOpenURL * * @param url starts URL of third-party application * @param delegate is the delegate that is used to receive sharing success or failure */ + (BOOL) handleOpenURL:(NSURL *) url delegate:(id<MPSDKProtocol>) delegate; /** * Meipai AppStore address */ + (NSURL *) installURLForMeipai; /** * Share video to Meipai * * @param pathUrl * One example of url address: assets-library://asset/asset.m4v?id=E5A30D8D-77AE-40D2-8755-8CA43CAA19EB&ext=m4v */ + (void) shareVideoAtPathToMeiPai:(NSURL *) pathURL; @end
The above is special notes of methods.
1. Drag MPShareSDK.framework to engineering and ensure Copy items if needed and Add to targets ticked.
2. After dragging framework, add the following code in info.plist (The main purpose is to add Meipai to white list and then return to your app after sharing to Meipai )
<!-- Add Meipai to white list --> <key>LSApplicationQueriesSchemes</key> <array> <string>mtmv</string> <string>mpsharesdk10</string></array><key>CFBundleURLTypes</key><array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <!-- Fill in mp+yourappkey, if appkey(clientid) is 1234567, fill in mp1234567 here --> <string>mp+yourappkey</string> </array> </dict> </array>
3. Next, call [MPShareSDK registerApp:@"yourappkey"] in - (BOOL) application:(UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *) launchOptions; of course,you also call the method in other any place as along as you ensure that the method has been called before calling and sharing it.
Write video to album at the place to share, and then send video to shareVideoAtPathToMeiPai: method in url of album. So far, sharing video to Meipai has been completed (Please pay attention to call isMeipaiSupportSharing method before sharing and giving out the corresponding operation according to BOOL value returned by the method, otherwise low version of Meipai will not be called) . The SDK just supports Meipai 4.1.0 or higher.
4. There will be corresponding callback for successful or failed sharing in Meipai app. It needs to call [MPShareSDK handleOpenURL:url delegate:yourdelegate]; in application:openURL:sourceApplication:annotation:, and then realize the corresponding protocol. The success parameter of protocol method is share result (success or failure)
If your items are written with Swift, please directly import #import <MPShareSDK/MPShareSDK.h> in yourappname-Bridging-Header.h (if not existed, create on directly), and then it can be used normally.