BBASMPackageManagementService.h
4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// BBASMPackageManagementService.h
// SWAN
//
// Created by baidu on 2018/10/24.
// Copyright © 2018 baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BBASMPMSCommon.h"
#import "BBASMPMSRequestItem.h"
NS_ASSUME_NONNULL_BEGIN
#define BBASMPMSService [BBASMPackageManagementService shared]
/**
* Package Management Service(PMS) is used for requesting swan app and swan core package.
*/
@interface BBASMPackageManagementService : NSObject
+ (nullable instancetype)shared;
- (instancetype)init UNAVAILABLE_ATTRIBUTE;
+ (instancetype)new UNAVAILABLE_ATTRIBUTE;
/**
* Use GET to request swan app package info from server.
*
* @param requestItem Local package info, `bundleID`, `category`, `packageVersion`, `frameworkVersion` are required,
* `subID`, `appSignature`, `extensionVersion` and `pagePath` are optional.
* @param appInfoBlock A call back to take back app info and how many packages need to download. It will be executed if exist before downloading the package.
* @param mainPackageProgress Call back of main package download progress if the main package exsit, maybe call back not on main thread.
* @param download Callback contains package info if successful, throw an error if failed to get the package.
* Maybe call back multiple times if there is more than one package to download.
* @param completion Callback contains the task state when all the download task completed.
*/
- (BOOL)getAppPackageWithRequestItem:(BBASMPMSRequestItem *)requestItem
appInfoBlock:(nullable PMSAppInfoBlock)appInfoBlock
mainPackageProgress:(nullable PMSDownloaderProgressBlock)mainPackageProgress
download:(nullable PMSPackageDownloadBlock)download
completion:(nullable PMSCompletionBlock)completion;
/**
* Use GET to request plugin, such as sConsole.
*
* @param requestItem `bundle_id`, `category`, `plugin_ver` are required.
* @param download Callback after plugin is downloaded or failed.
* @param completion Callback contains the task state when all the download task completed.
*/
- (void)getPluginWithRequestItem:(BBASMPMSRequestItem *)requestItem
download:(nullable PMSPackageDownloadBlock)download
completion:(nullable PMSCompletionBlock)completion;
/**
* Use POST to request a package list from server.
*
* @param requestItem Local package info, `bundleIDs` are required.
* @param appInfoListBlock App infos call back. If there are app info array from server, the block will be executed if exist before downloading the package.
* @param download Callback contains package info if successful, throw an error if failed to get the package.
* Maybe call back multiple times if there is more than one package to download.
* @param completion Callback contains the task state when all the download task completed.
*/
- (void)getAppPackageListWithRequestItem:(BBASMPMSRequestItem *)requestItem
appInfoListBlock:(nullable PMSAppInfoListBlock)appInfoListBlock
download:(nullable PMSAppListDownloadBlock)download
completion:(nullable PMSAppListCompletionBlock)completion;
/// Use POST to request openbundleid from server with appKeys,need use bdtls
/// @param appID 当前appID
/// @param appKeys 需转换appKeys数组
/// @param success 成功回调
/// @param failure 失败回调
+ (void)requestPackageBundleIDWithAppID:(NSString *)appID
appKeys:(NSArray *)appKeys
success:(nullable void (^)(NSDictionary * _Nullable responseHeaders, NSDictionary *responseData))success
failure:(nullable void (^)(NSError *error, NSInteger reponseStausCode))failure;
/// Use POST to request Dependencies
/// @param requestItem 请求信息
/// @param download 成功回调
/// @param completion 失败回调
- (void)getDependenciesWithRequestItem:(BBASMPMSRequestItem *)requestItem
download:(nullable PMSDependenciesDownloadBlock)download
completion:(nullable PMSDependenciesCompletionBlock)completion;
@end
NS_ASSUME_NONNULL_END