[WIP] firebase init Error
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4239996e802e74b9397d6681050057a0
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2529cb0d15c3749bb952ed88321c8511
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf50ab4f25f95461f880b2ac57e7fbdb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// GAConstants.h
|
||||
// GA
|
||||
//
|
||||
// Created by on 2018/8/9.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
#pragma mark - typedef
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* Debug 模式,用于检验数据导入是否正确。
|
||||
*
|
||||
* Debug模式有三种选项:
|
||||
* GALoggerDebugOff - 关闭 DEBUG 模式
|
||||
* GALoggerDebugAndTrack - 打开 DEBUG 模式,并将数据导入到 BILog 中
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, GADebugMode) {
|
||||
GALoggerDebugOff,
|
||||
GALoggerDebugAndTrack,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, GAEventType) {
|
||||
GA_TRACK = 1, //默认类型
|
||||
GA_CION = 2, //金流相关事件
|
||||
GA_PAY = 3, //支付相关事件
|
||||
GA_GAME = 4, //游戏行为
|
||||
GA_LOGIN = 5, //登录注册相关事件
|
||||
GA_PUSH = 6, //推送相关事件
|
||||
GA_ADBOX = 7, //adbox相关事件
|
||||
GA_PREFORMANCE = 8, //性能上报相关事件
|
||||
GA_SDK = 9, //SDK相关事件
|
||||
GA_ABTest = 10, //abtest相关事件
|
||||
GA_PROFILE = 11, //设置用户特征
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, GAProfileEvent) {
|
||||
GA_PROFILE_SET = 1,
|
||||
GA_PROFILE_SET_ONCE =2,
|
||||
GA_PROFILE_INCREMENT =3,
|
||||
GA_PROFILE_DELETE =4,
|
||||
GA_PROFILE_UNSET =5,
|
||||
};
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, GAServerUrl) {
|
||||
GA_INTERNAL = 1, //国内的
|
||||
GA_INTERNATIONAL = 2, //国外的
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6af2b2454f07489aa9206cf79ec2d46
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// GASDK.h
|
||||
// GASDK
|
||||
//
|
||||
// Created by 周翔宇 on 2020/1/9.
|
||||
// Copyright © 2020 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "GAConstants.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface GASDK : NSObject
|
||||
|
||||
/**
|
||||
获取项目组的GA实例
|
||||
@param projectId BI分配的projectId
|
||||
*/
|
||||
+ (instancetype)getGAlog:(NSString *)projectId;
|
||||
|
||||
/**
|
||||
获取SDK的GA实例
|
||||
@param projectId BI分配的projectId
|
||||
*/
|
||||
+ (instancetype)getSDKGAlog:(NSString *)projectId;
|
||||
|
||||
/**
|
||||
GASDK初始化方法
|
||||
@param gameId 游戏id
|
||||
@param clientId 客户端id
|
||||
@param commonParams 通用参数,每次上报都会带上这儿设置的参数
|
||||
@param serverUrl 地址
|
||||
*/
|
||||
- (void)initWithGameId:(NSString *)gameId clientId:(NSString *)clientId withCommonParams:(NSDictionary *)commonParams serverUrl:(GAServerUrl)serverUrl;
|
||||
|
||||
/**
|
||||
设置 userId,登录成功后设置
|
||||
|
||||
@param userId 用户 id
|
||||
*/
|
||||
- (void)setUserId:(NSString *)userId;
|
||||
|
||||
/**
|
||||
设置 yidunDeviceid
|
||||
|
||||
@param yidunDeviceid 易盾设备指纹
|
||||
*/
|
||||
+ (void)setYidunDeviceid:(NSString *)yidunDeviceid;
|
||||
|
||||
/**
|
||||
上报日志
|
||||
|
||||
@param object BI日志,传入的数据为完整的日志格式数据,内部只将数据转为 json 字符串上报到日志服
|
||||
*/
|
||||
- (void)track:(NSDictionary *)object type:(GAEventType)type event:(NSString *)event;
|
||||
|
||||
/**
|
||||
上报日志
|
||||
|
||||
@param object BI日志,传入的数据为完整的日志格式数据,内部只将数据转为 json 字符串上报到日志服
|
||||
@param complate 上报结果回调
|
||||
*/
|
||||
- (void)track:(NSDictionary *)object type:(GAEventType)type event:(NSString *)event complate:(void(^)(BOOL isSuccess))complate;
|
||||
|
||||
/**
|
||||
获取上报数据
|
||||
|
||||
@param object BI日志,传入的数据为完整的日志格式数据,内部只将数据转为 json 字符串上报到日志服
|
||||
*/
|
||||
- (NSDictionary *)getParamasWithObject:(NSDictionary *)object type:(GAEventType)type event:(NSString *)event;
|
||||
|
||||
/**
|
||||
获取上报url
|
||||
*/
|
||||
-(NSString *)requestUrl;
|
||||
|
||||
/**
|
||||
上报日志
|
||||
|
||||
@param object BI日志,不传事件类型,默认为track
|
||||
*/
|
||||
- (void)track:(NSDictionary *)object event:(NSString *)event;
|
||||
|
||||
|
||||
/**
|
||||
设置用户特征
|
||||
|
||||
@param object BI日志,不传事件类型,默认为track
|
||||
*/
|
||||
- (void)trackProfile:(NSDictionary *)object event:(GAProfileEvent)event;
|
||||
|
||||
/**
|
||||
是否log输出
|
||||
|
||||
@param enableLog YES log输出,NO 不输出,默认为YES
|
||||
*/
|
||||
+ (void)enableLog:(BOOL)enableLog;
|
||||
/**
|
||||
获取 SDK 版本号
|
||||
|
||||
@return SDK 版本号
|
||||
*/
|
||||
+ (NSString *)getApiVersion;
|
||||
|
||||
/**
|
||||
设置 IDFA,可选,如果项目组需要在打点上传idfa,则需调用此方法传入
|
||||
|
||||
@param idfa 广告标识符
|
||||
*/
|
||||
+ (void)setIDFA: (NSString *)idfa;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02ccb06723b244c98b38827d60f77b0a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
# 版本2.1.2
|
||||
### 更新日期
|
||||
2021-04-16
|
||||
##更新说明
|
||||
1.修改idfa的获取方法
|
||||
|
||||
|
||||
# 版本2.1.1
|
||||
### 更新日期
|
||||
2021-03-08
|
||||
##更新说明
|
||||
1.修改idfa的获取方法
|
||||
2.添加外部直接上报的接口
|
||||
|
||||
|
||||
|
||||
```
|
||||
1. 修改上报时 传输的事件数目 2020/11/18
|
||||
2. 添加对外传入idfa的接口 2021/02/20
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c20bdaa81053b4c39bbb3c4fb1807166
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c266a70afd54453eb3d623acd67b3d5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cdb1f616497f4ff784238b006420e03
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
framework module GASDK {
|
||||
umbrella header "GASDK.h"
|
||||
export *
|
||||
|
||||
module * { export * }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4f79f6ccd0fd499f89337f67f83d056
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
# 版本2.1.2
|
||||
### 更新日期
|
||||
2021-04-16
|
||||
##更新说明
|
||||
1.修改idfa的获取方法
|
||||
|
||||
|
||||
# 版本2.1.1
|
||||
### 更新日期
|
||||
2021-03-08
|
||||
##更新说明
|
||||
1.修改idfa的获取方法
|
||||
2.添加外部直接上报的接口
|
||||
|
||||
|
||||
|
||||
```
|
||||
1. 修改上报时 传输的事件数目 2020/11/18
|
||||
2. 添加对外传入idfa的接口 2021/02/20
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13d359c716a8b4a2fba297d26f33148b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01a5f892667db4d169259dcf80b4f7b7
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a43d7a24bf8454feeb1a9b9c84983133
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// NSObject+TYModelToDict.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSObject (TYModelToDict)
|
||||
|
||||
/**
|
||||
* 模型转字典
|
||||
*
|
||||
* @return 字典
|
||||
*/
|
||||
- (NSDictionary *_Nullable)TYDictionaryFromModel;
|
||||
|
||||
/**
|
||||
* 带model的数组或字典转字典
|
||||
*
|
||||
* @param object 带model的数组或字典转
|
||||
*
|
||||
* @return 字典
|
||||
*/
|
||||
- (id _Nullable )TYObjectFromObject:(nonnull id)object;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5f0b232213734e83b1d7c16962b0eff
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// NSString+TYProject.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (TYProject)
|
||||
|
||||
|
||||
/**
|
||||
空
|
||||
*/
|
||||
- (BOOL)isEmpty;
|
||||
/**
|
||||
非空
|
||||
*/
|
||||
- (BOOL)isNotEmpty;
|
||||
|
||||
|
||||
/**
|
||||
md5
|
||||
*/
|
||||
- (NSString *)md5;
|
||||
|
||||
|
||||
- (BOOL)checkTel;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e56bec217684c47ae847358a9fef3fc4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
##1.3.4 更新时间 2022-03-12
|
||||
### 更新内容
|
||||
1 新增toast工具
|
||||
2 新增hud工具
|
||||
3 当前包Mac参数没有你猜加密,查看位置:TYDeviceInfoModel.h k_macParamUseNiCai = 1 有你猜
|
||||
|
||||
|
||||
##1.3.3 更新时间 2022-02-09
|
||||
### 更新内容
|
||||
1. mac参数加密开关 该包该参数没有你猜加密
|
||||
|
||||
## 1.3.2 更新时间 2021-09-22
|
||||
### 更新内容
|
||||
1. 新增hud工具
|
||||
|
||||
### 1.3.1 更新时间 2021-06-24
|
||||
### 更新内容
|
||||
1. 新增返程回基类,处理返回数据与公共数据分发
|
||||
|
||||
### 1.3.0 更新时间 2021-06-15
|
||||
### 更新内容
|
||||
* 更新网络工具, 不同工具持有不同http会话
|
||||
* 更新网络工具, 不同工具持有不同http会话地址
|
||||
|
||||
### 1.2.0 更新时间 2021-03-18
|
||||
### 更新内容
|
||||
1.添加外部获取deviceId的方法,添加deviceId的获取监听
|
||||
2.添加网络状态监听,发送网络状态通知
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 236296da3e99f4b77a2a99a9e41942ce
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// TDKIndicatorHelper.h
|
||||
// TYUICoreKit
|
||||
//
|
||||
// Created by 史良 on 2021/12/9.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDKIndicatorHelper : NSObject
|
||||
|
||||
|
||||
/// 弹出toast指示器
|
||||
/// @param toast 文案
|
||||
/// @param alertView 文案视图
|
||||
+ (void)alertTDKIndicatorToastWith:(NSString *)toast alertview:(UIView *)alertView;
|
||||
|
||||
|
||||
/// 弹出hud指示器
|
||||
/// @param alertView 文案视图
|
||||
+ (void)alertTDKIndicatorHUDWithAlertview:(UIView *)alertView;
|
||||
|
||||
|
||||
/// 消失指示器
|
||||
/// @param alertView 文案视图
|
||||
+ (void)dissmissTDKIndicatorWith:(UIView *)alertView;;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5cc7b4830cb8440a9240a3d95db9c45
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,411 @@
|
||||
//
|
||||
// TDKMBProgressHUD.h
|
||||
// Version 1.2.0
|
||||
// Created by Matej Bukovinski on 2.4.09.
|
||||
//
|
||||
|
||||
// This code is distributed under the terms and conditions of the MIT license.
|
||||
|
||||
// Copyright © 2009-2016 Matej Bukovinski
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@class TDKMBBackgroundView;
|
||||
@protocol TDKMBProgressHUDDelegate;
|
||||
|
||||
|
||||
extern CGFloat const TDKMBProgressMaxOffset;
|
||||
|
||||
typedef NS_ENUM(NSInteger, TDKMBProgressHUDMode) {
|
||||
/// UIActivityIndicatorView.
|
||||
TDKMBProgressHUDModeIndeterminate,
|
||||
/// A round, pie-chart like, progress view.
|
||||
TDKMBProgressHUDModeDeterminate,
|
||||
/// Horizontal progress bar.
|
||||
TDKMBProgressHUDModeDeterminateHorizontalBar,
|
||||
/// Ring-shaped progress view.
|
||||
TDKMBProgressHUDModeAnnularDeterminate,
|
||||
/// Shows a custom view.
|
||||
TDKMBProgressHUDModeCustomView,
|
||||
/// Shows only labels.
|
||||
TDKMBProgressHUDModeText
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, TDKMBProgressHUDAnimation) {
|
||||
/// Opacity animation
|
||||
TDKMBProgressHUDAnimationFade,
|
||||
/// Opacity + scale animation (zoom in when appearing zoom out when disappearing)
|
||||
TDKMBProgressHUDAnimationZoom,
|
||||
/// Opacity + scale animation (zoom out style)
|
||||
TDKMBProgressHUDAnimationZoomOut,
|
||||
/// Opacity + scale animation (zoom in style)
|
||||
TDKMBProgressHUDAnimationZoomIn
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, TDKMBProgressHUDBackgroundStyle) {
|
||||
/// Solid color background
|
||||
TDKMBProgressHUDBackgroundStyleSolidColor,
|
||||
/// UIVisualEffectView or UIToolbar.layer background view
|
||||
TDKMBProgressHUDBackgroundStyleBlur
|
||||
};
|
||||
|
||||
typedef void (^TDKMBProgressHUDCompletionBlock)(void);
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* Displays a simple HUD window containing a progress indicator and two optional labels for short messages.
|
||||
*
|
||||
* This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class.
|
||||
* The TDKMBProgressHUD window spans over the entire space given to it by the initWithFrame: constructor and catches all
|
||||
* user input on this region, thereby preventing the user operations on components below the view.
|
||||
*
|
||||
* @note To still allow touches to pass through the HUD, you can set hud.userInteractionEnabled = NO.
|
||||
* @attention TDKMBProgressHUD is a UI class and should therefore only be accessed on the main thread.
|
||||
*/
|
||||
@interface TDKMBProgressHUD : UIView
|
||||
|
||||
/**
|
||||
* Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:.
|
||||
*
|
||||
* @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden.
|
||||
*
|
||||
* @param view The view that the HUD will be added to
|
||||
* @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use
|
||||
* animations while appearing.
|
||||
* @return A reference to the created HUD.
|
||||
*
|
||||
* @see hideHUDForView:animated:
|
||||
* @see animationType
|
||||
*/
|
||||
+ (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated;
|
||||
|
||||
/// @name Showing and hiding
|
||||
|
||||
/**
|
||||
* Finds the top-most HUD subview that hasn't finished and hides it. The counterpart to this method is showHUDAddedTo:animated:.
|
||||
*
|
||||
* @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden.
|
||||
*
|
||||
* @param view The view that is going to be searched for a HUD subview.
|
||||
* @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use
|
||||
* animations while disappearing.
|
||||
* @return YES if a HUD was found and removed, NO otherwise.
|
||||
*
|
||||
* @see showHUDAddedTo:animated:
|
||||
* @see animationType
|
||||
*/
|
||||
+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated;
|
||||
|
||||
/**
|
||||
* Finds the top-most HUD subview that hasn't finished and returns it.
|
||||
*
|
||||
* @param view The view that is going to be searched.
|
||||
* @return A reference to the last HUD subview discovered.
|
||||
*/
|
||||
+ (nullable TDKMBProgressHUD *)HUDForView:(UIView *)view NS_SWIFT_NAME(forView(_:));
|
||||
|
||||
/**
|
||||
* A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with
|
||||
* view.bounds as the parameter.
|
||||
*
|
||||
* @param view The view instance that will provide the bounds for the HUD. Should be the same instance as
|
||||
* the HUD's superview (i.e., the view that the HUD will be added to).
|
||||
*/
|
||||
- (instancetype)initWithView:(UIView *)view;
|
||||
|
||||
/**
|
||||
* Displays the HUD.
|
||||
*
|
||||
* @note You need to make sure that the main thread completes its run loop soon after this method call so that
|
||||
* the user interface can be updated. Call this method when your task is already set up to be executed in a new thread
|
||||
* (e.g., when using something like NSOperation or making an asynchronous call like NSURLRequest).
|
||||
*
|
||||
* @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use
|
||||
* animations while appearing.
|
||||
*
|
||||
* @see animationType
|
||||
*/
|
||||
- (void)showAnimated:(BOOL)animated;
|
||||
|
||||
/**
|
||||
* Hides the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to
|
||||
* hide the HUD when your task completes.
|
||||
*
|
||||
* @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use
|
||||
* animations while disappearing.
|
||||
*
|
||||
* @see animationType
|
||||
*/
|
||||
- (void)hideAnimated:(BOOL)animated;
|
||||
|
||||
/**
|
||||
* Hides the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to
|
||||
* hide the HUD when your task completes.
|
||||
*
|
||||
* @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use
|
||||
* animations while disappearing.
|
||||
* @param delay Delay in seconds until the HUD is hidden.
|
||||
*
|
||||
* @see animationType
|
||||
*/
|
||||
- (void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay;
|
||||
|
||||
/**
|
||||
* The HUD delegate object. Receives HUD state notifications.
|
||||
*/
|
||||
@property (weak, nonatomic) id<TDKMBProgressHUDDelegate> delegate;
|
||||
|
||||
/**
|
||||
* Called after the HUD is hidden.
|
||||
*/
|
||||
@property (copy, nullable) TDKMBProgressHUDCompletionBlock completionBlock;
|
||||
|
||||
/**
|
||||
* Grace period is the time (in seconds) that the invoked method may be run without
|
||||
* showing the HUD. If the task finishes before the grace time runs out, the HUD will
|
||||
* not be shown at all.
|
||||
* This may be used to prevent HUD display for very short tasks.
|
||||
* Defaults to 0 (no grace time).
|
||||
* @note The graceTime needs to be set before the hud is shown. You thus can't use `showHUDAddedTo:animated:`,
|
||||
* but instead need to alloc / init the HUD, configure the grace time and than show it manually.
|
||||
*/
|
||||
@property (assign, nonatomic) NSTimeInterval graceTime;
|
||||
|
||||
/**
|
||||
* The minimum time (in seconds) that the HUD is shown.
|
||||
* This avoids the problem of the HUD being shown and than instantly hidden.
|
||||
* Defaults to 0 (no minimum show time).
|
||||
*/
|
||||
@property (assign, nonatomic) NSTimeInterval minShowTime;
|
||||
|
||||
/**
|
||||
* Removes the HUD from its parent view when hidden.
|
||||
* Defaults to NO.
|
||||
*/
|
||||
@property (assign, nonatomic) BOOL removeFromSuperViewOnHide;
|
||||
|
||||
/// @name Appearance
|
||||
|
||||
/**
|
||||
* TDKMBProgressHUD operation mode. The default is TDKMBProgressHUDModeIndeterminate.
|
||||
*/
|
||||
@property (assign, nonatomic) TDKMBProgressHUDMode mode;
|
||||
|
||||
/**
|
||||
* A color that gets forwarded to all labels and supported indicators. Also sets the tintColor
|
||||
* for custom views on iOS 7+. Set to nil to manage color individually.
|
||||
* Defaults to semi-translucent black on iOS 7 and later and white on earlier iOS versions.
|
||||
*/
|
||||
@property (strong, nonatomic, nullable) UIColor *contentColor UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/**
|
||||
* The animation type that should be used when the HUD is shown and hidden.
|
||||
*/
|
||||
@property (assign, nonatomic) TDKMBProgressHUDAnimation animationType UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/**
|
||||
* The bezel offset relative to the center of the view. You can use TDKMBProgressMaxOffset
|
||||
* and -TDKMBProgressMaxOffset to move the HUD all the way to the screen edge in each direction.
|
||||
* E.g., CGPointMake(0.f, TDKMBProgressMaxOffset) would position the HUD centered on the bottom edge.
|
||||
*/
|
||||
@property (assign, nonatomic) CGPoint offset UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/**
|
||||
* The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views).
|
||||
* This also represents the minimum bezel distance to the edge of the HUD view.
|
||||
* Defaults to 20.f
|
||||
*/
|
||||
@property (assign, nonatomic) CGFloat margin UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/**
|
||||
* The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size).
|
||||
*/
|
||||
@property (assign, nonatomic) CGSize minSize UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/**
|
||||
* Force the HUD dimensions to be equal if possible.
|
||||
*/
|
||||
@property (assign, nonatomic, getter = isSquare) BOOL square UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/**
|
||||
* When enabled, the bezel center gets slightly affected by the device accelerometer data.
|
||||
* Defaults to NO.
|
||||
*
|
||||
* @note This can cause main thread checker assertions on certain devices. https://github.com/jdg/TDKMBProgressHUD/issues/552
|
||||
*/
|
||||
@property (assign, nonatomic, getter=areDefaultMotionEffectsEnabled) BOOL defaultMotionEffectsEnabled UI_APPEARANCE_SELECTOR;
|
||||
|
||||
/// @name Progress
|
||||
|
||||
/**
|
||||
* The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0.
|
||||
*/
|
||||
@property (assign, nonatomic) float progress;
|
||||
|
||||
/// @name ProgressObject
|
||||
|
||||
/**
|
||||
* The NSProgress object feeding the progress information to the progress indicator.
|
||||
*/
|
||||
@property (strong, nonatomic, nullable) NSProgress *progressObject;
|
||||
|
||||
/// @name Views
|
||||
|
||||
/**
|
||||
* The view containing the labels and indicator (or customView).
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) TDKMBBackgroundView *bezelView;
|
||||
|
||||
/**
|
||||
* View covering the entire HUD area, placed behind bezelView.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) TDKMBBackgroundView *backgroundView;
|
||||
|
||||
/**
|
||||
* The UIView (e.g., a UIImageView) to be shown when the HUD is in TDKMBProgressHUDModeCustomView.
|
||||
* The view should implement intrinsicContentSize for proper sizing. For best results use approximately 37 by 37 pixels.
|
||||
*/
|
||||
@property (strong, nonatomic, nullable) UIView *customView;
|
||||
|
||||
/**
|
||||
* A label that holds an optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit
|
||||
* the entire text.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) UILabel *label;
|
||||
|
||||
/**
|
||||
* A label that holds an optional details message displayed below the labelText message. The details text can span multiple lines.
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) UILabel *detailsLabel;
|
||||
|
||||
/**
|
||||
* A button that is placed below the labels. Visible only if a target / action is added and a title is assigned..
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) UIButton *button;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol TDKMBProgressHUDDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* Called after the HUD was fully hidden from the screen.
|
||||
*/
|
||||
- (void)hudWasHidden:(TDKMBProgressHUD *)hud;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
* A progress view for showing definite progress by filling up a circle (pie chart).
|
||||
*/
|
||||
@interface TDKMBRoundProgressView : UIView
|
||||
|
||||
/**
|
||||
* Progress (0.0 to 1.0)
|
||||
*/
|
||||
@property (nonatomic, assign) float progress;
|
||||
|
||||
/**
|
||||
* Indicator progress color.
|
||||
* Defaults to white [UIColor whiteColor].
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *progressTintColor;
|
||||
|
||||
/**
|
||||
* Indicator background (non-progress) color.
|
||||
* Only applicable on iOS versions older than iOS 7.
|
||||
* Defaults to translucent white (alpha 0.1).
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *backgroundTintColor;
|
||||
|
||||
/*
|
||||
* Display mode - NO = round or YES = annular. Defaults to round.
|
||||
*/
|
||||
@property (nonatomic, assign, getter = isAnnular) BOOL annular;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
* A flat bar progress view.
|
||||
*/
|
||||
@interface TDKMBBarProgressView : UIView
|
||||
|
||||
/**
|
||||
* Progress (0.0 to 1.0)
|
||||
*/
|
||||
@property (nonatomic, assign) float progress;
|
||||
|
||||
/**
|
||||
* Bar border line color.
|
||||
* Defaults to white [UIColor whiteColor].
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *lineColor;
|
||||
|
||||
/**
|
||||
* Bar background color.
|
||||
* Defaults to clear [UIColor clearColor];
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *progressRemainingColor;
|
||||
|
||||
/**
|
||||
* Bar progress color.
|
||||
* Defaults to white [UIColor whiteColor].
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *progressColor;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TDKMBBackgroundView : UIView
|
||||
|
||||
/**
|
||||
* The background style.
|
||||
* Defaults to TDKMBProgressHUDBackgroundStyleBlur.
|
||||
*/
|
||||
@property (nonatomic) TDKMBProgressHUDBackgroundStyle style;
|
||||
|
||||
/**
|
||||
* The blur effect style, when using TDKMBProgressHUDBackgroundStyleBlur.
|
||||
* Defaults to UIBlurEffectStyleLight.
|
||||
*/
|
||||
@property (nonatomic) UIBlurEffectStyle blurEffectStyle;
|
||||
|
||||
/**
|
||||
* The background color or the blur tint color.
|
||||
*
|
||||
* Defaults to nil on iOS 13 and later and
|
||||
* `[UIColor colorWithWhite:0.8f alpha:0.6f]`
|
||||
* on older systems.
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) UIColor *color;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 791c5bb944a6f4c0f9a52a53d9cefb3d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
// TYBaseDataModel.h
|
||||
// TYSDKCoreKit
|
||||
//
|
||||
// Created by hui on 2021/3/25.
|
||||
// Copyright © 2021 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TYDeviceInfoModel.h"
|
||||
|
||||
|
||||
|
||||
//NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface TYBaseDataModel : NSObject
|
||||
|
||||
@property (nonatomic, strong) TYDeviceInfoModel *deviceInfo;
|
||||
|
||||
@property (nonatomic, copy) NSString *serverUrl;
|
||||
@property (nonatomic, copy) NSString *clientId;
|
||||
@property (nonatomic, copy) NSString *gameId;
|
||||
@property (nonatomic, copy) NSString *cloudId;
|
||||
@property (nonatomic, copy) NSString *sdkTrackId;
|
||||
@property (nonatomic, copy) NSString *sdkVersion;
|
||||
@property (nonatomic, assign) NSInteger appId;
|
||||
@property (nonatomic, assign) NSInteger userId;
|
||||
//GA
|
||||
@property (nonatomic, copy) NSString *projectId;
|
||||
|
||||
/// 理论上所有SDK的数据层 基本数据一致, 以防以后特殊需求 每个SDK单独持有一份自己的数据层
|
||||
/// 除主初始化SDK外(xysdk), 其他SDK的数据层(basedata实例)使用此方法装载数据;其他SDK在主SDK初始化后 来此获取数据
|
||||
/// @param dataModel 某个SDK的数据层模型
|
||||
+ (NSMutableDictionary *)updateDataModelWith:(TYBaseDataModel *)dataModel;
|
||||
|
||||
|
||||
/// 主初始化SDK(xysdk)的数据层更新数据
|
||||
/// @param baseDataDic XYSDK中的数据层所有数据
|
||||
+ (void)saveDataWith:(NSMutableDictionary *)baseDataDic;
|
||||
|
||||
/**
|
||||
获取基本请求信息
|
||||
|
||||
@return 基本请求信息
|
||||
*/
|
||||
- (NSMutableDictionary *)getRequestParameters;
|
||||
|
||||
/**
|
||||
获取基本请求信息
|
||||
|
||||
@return 基本请求信息
|
||||
*/
|
||||
- (NSMutableDictionary *)getRequestParametersWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
|
||||
|
||||
/**
|
||||
获取GA数据
|
||||
|
||||
@return GA基本数据
|
||||
*/
|
||||
- (NSMutableDictionary *)getInitGAParam;
|
||||
|
||||
/**
|
||||
获取全部数据,基本数据和GA数据
|
||||
|
||||
@param dic 自定义数据
|
||||
|
||||
@return 基本数据和GA数据及自定义数据
|
||||
*/
|
||||
- (NSMutableDictionary *)getFullParmatersWithDic:(NSDictionary *)dic;
|
||||
|
||||
@end
|
||||
|
||||
//NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23a6bf23a63e942f1a697694aad1effe
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// XYResp.h
|
||||
// XYSDK
|
||||
//
|
||||
// Created by 刘磊 on 2018/7/26.
|
||||
// Copyright © 2018年 刘磊. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, TYCoreErrCode) {
|
||||
TYCoreSuccess = 0, /**< 登录/分享成功 */
|
||||
TYCoreErrCodeCommon = -1, /**< 普通错误类型/支付失败 */
|
||||
TYCoreErrCodeUserCancel = -2, /**< 用户点击取消并返回 */
|
||||
TYCoreErrCodeSentFail = -3, /**< 发送失败/参数异常 */
|
||||
TYCoreErrCodeAuthDeny = -4, /**< 授权/签名失败 */
|
||||
TYCoreErrCodeUnsupport = -5, /**< 登录方式不支持 */
|
||||
TYCoreErrCodeNetwork = -6, /**< 网络异常 */
|
||||
TYCoreErrCodeHadBind = -7, /**< 已绑定过 */
|
||||
TYCoreErrTokenExpire = -8, /**< token已过期 */
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TYWXGetType) {
|
||||
TYWXGetLoginInfo = 0, // 微信登录数据
|
||||
TYWXGetUserInfo = 1, // 微信获取用户数据
|
||||
TYWXGetAuthorize = 2, // 微信获取授权
|
||||
};
|
||||
|
||||
/** 微信分享的目标场景 */
|
||||
typedef NS_ENUM(NSUInteger, TYShareScene) {
|
||||
TYShareSceneSession = 0, /**< 好友 */
|
||||
TYShareSceneTimeline = 1, /**< 朋友圈 */
|
||||
TYShareSceneFavorite = 2, /**< 收藏 */
|
||||
};
|
||||
|
||||
|
||||
@interface TYBaseResp : NSObject
|
||||
|
||||
/** 错误码 */
|
||||
@property (nonatomic, readwrite, assign) NSInteger errCode;
|
||||
/** 错误提示字符串 */
|
||||
@property (nonatomic, readwrite, copy) NSString *errStr;
|
||||
/** 响应数据 */
|
||||
@property (nonatomic, readwrite, retain) id respObj;
|
||||
|
||||
|
||||
+ (instancetype)responseWithCode:(NSInteger)code errStr:(NSString *)str;
|
||||
+ (instancetype)responseWithCode:(NSInteger)code errStr:(NSString *)str objc:(id)objc;
|
||||
|
||||
/** 成功回调 errCode = 0 */
|
||||
+ (instancetype)successRespWithStr:(NSString *)errStr;
|
||||
+ (instancetype)successRespWithStr:(NSString *)errStr obj:(id)respObj;
|
||||
/** 默认错误类型 errorCode = -1 */
|
||||
+ (instancetype)commonError:(NSString *)errStr;
|
||||
/** 发送失败 网络或数据异常 errCode = -3 */
|
||||
+ (instancetype)sendError:(NSString *)errStr;
|
||||
/** 网络异常 */
|
||||
+ (instancetype)networkError;
|
||||
/** 封禁错误类型 errorCode = -9 */
|
||||
/** 网络异常 */
|
||||
+ (instancetype)forbiddenError:(NSString *)errStr;
|
||||
/** 参数检查->异常 */
|
||||
+ (instancetype)checkParamError;
|
||||
+ (instancetype)checkParamErrorWithMsg:(NSString *)errStr;
|
||||
|
||||
+ (instancetype)payNetError:(NSError *)error;
|
||||
|
||||
@end
|
||||
|
||||
typedef void(^TYBaseRespBlock)(TYBaseResp * _Nonnull resp);
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50ba1c16f8f1146a4b435b1eecf65554
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
// TYCompatibilityMacros.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef TYCompatibilityMacros_h
|
||||
#define TYCompatibilityMacros_h
|
||||
|
||||
#ifdef API_AVAILABLE
|
||||
#define TY_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__)
|
||||
#else
|
||||
#define TY_API_AVAILABLE(...)
|
||||
#endif // API_AVAILABLE
|
||||
|
||||
#ifdef API_UNAVAILABLE
|
||||
#define TY_API_UNAVAILABLE(...) API_UNAVAILABLE(__VA_ARGS__)
|
||||
#else
|
||||
#define TY_API_UNAVAILABLE(...)
|
||||
#endif // API_UNAVAILABLE
|
||||
|
||||
#if __has_warning("-Wunguarded-availability-new")
|
||||
#define TY_CAN_USE_AT_AVAILABLE 1
|
||||
#else
|
||||
#define TY_CAN_USE_AT_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#if ((__IPHONE_OS_VERSION_MAX_ALLOWED && __IPHONE_OS_VERSION_MAX_ALLOWED < 100000) || (__MAC_OS_VERSION_MAX_ALLOWED && __MAC_OS_VERSION_MAX_ALLOWED < 101200) ||(__WATCH_OS_MAX_VERSION_ALLOWED && __WATCH_OS_MAX_VERSION_ALLOWED < 30000) ||(__TV_OS_MAX_VERSION_ALLOWED && __TV_OS_MAX_VERSION_ALLOWED < 100000))
|
||||
#define TY_CAN_INCLUDE_SESSION_TASK_METRICS 0
|
||||
#else
|
||||
#define TY_CAN_INCLUDE_SESSION_TASK_METRICS 1
|
||||
#endif
|
||||
|
||||
#endif /* TYCompatibilityMacros_h */
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1869c9f88fe846e7aebb072ef9a17d3
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// TYCoreHttpStatus.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TYReachability.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger,TYCoreHttpType){
|
||||
TYCoreHttpType_NotReachable = 1,
|
||||
TYCoreHttpType_wifi,
|
||||
TYCoreHttpTyoe_wwan,
|
||||
};
|
||||
|
||||
#define kTYCNetStatusChangedNotification @"kTYCNetStatusChangedNotification"
|
||||
|
||||
@interface TYCoreHttpStatus : NSObject
|
||||
|
||||
/** 当前网络状态 */
|
||||
+ (TYCoreHttpType)httpType;
|
||||
|
||||
/** 有网 */
|
||||
+ (BOOL)isReachable;
|
||||
+ (BOOL)isAppleReachable;
|
||||
|
||||
/** 当前是否处于wifi */
|
||||
+ (BOOL)isWifiEnable;
|
||||
|
||||
+ (NSString *)getCurrentNetworkType;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d206025712554764a1daf1db77b1272
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
// TYDeviceInfoModel.h
|
||||
// TYSDKCoreKit
|
||||
//
|
||||
// Created by hui on 2021/3/24.
|
||||
// Copyright © 2021 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#define k_macParamUseNiCai 0
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYDeviceInfoModel : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *idfa;
|
||||
@property (nonatomic, copy) NSString *packageName;
|
||||
@property (nonatomic, copy) NSString *appVersion;
|
||||
@property (nonatomic, copy) NSString *UUID;
|
||||
@property (nonatomic, copy) NSString *macAddress;
|
||||
@property (nonatomic, copy) NSString *deviceId;
|
||||
@property (nonatomic, assign) NSNumber *carrier; //运营商
|
||||
@property (nonatomic, assign) BOOL isJailBreak; //是否越狱
|
||||
|
||||
/// 获取设备信息相关参数
|
||||
- (NSDictionary *)getDeviceParameters;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e7cb4c5382354188ab75311a5d7fac2
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// TYEncrypt.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TYGTMBase64.h"
|
||||
|
||||
@interface TYEncrypt : NSObject
|
||||
|
||||
+ (NSString *)encryptStringUseBase64:(NSString *)clearText;
|
||||
|
||||
+ (NSDictionary *)encryptParametersWithDict:(NSDictionary *)dict;
|
||||
|
||||
+ (NSDictionary *)encryptParametersWithoutNiCi:(NSDictionary *)dict;
|
||||
|
||||
+ (NSString *)desNicaiAndBase64:(NSString *)originalStr;
|
||||
|
||||
+ (NSString *)decNicaiAndBase64:(NSString *)originalStr;
|
||||
|
||||
+ (NSString *)md5:(NSString *)str;
|
||||
|
||||
+ (NSString *)signatureParametersWithDict:(NSDictionary *)dic secret_key:(NSString *)secret_key;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface NSString (sha256)
|
||||
|
||||
//SHA256加密
|
||||
- (NSString*)sha256;
|
||||
@end
|
||||
|
||||
@interface NSString(NICAI)
|
||||
|
||||
- (NSString *)nicaiString;
|
||||
|
||||
- (NSString *)xor_String;
|
||||
|
||||
- (NSString *)xor_DecString;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSData(NICAI)
|
||||
|
||||
- (NSData *)xor_decrypt;
|
||||
|
||||
- (NSData *)xor_encrypt;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53c5085fea9cf4460bd2a199ce956794
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// TYFileManager.h
|
||||
// GMFramework
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface TYFileManager : NSObject
|
||||
/** @name 读取 */
|
||||
/**
|
||||
加载文件
|
||||
@param path 文件路径
|
||||
@return NSObject 文件中的数据
|
||||
*/
|
||||
+ (id )loadDataFromPath:(NSString *)path;
|
||||
|
||||
/**
|
||||
异步加载文件
|
||||
@param path 文件路径
|
||||
@param callback 加载完成后回调
|
||||
@return BOOL 同步返回文件是否存在
|
||||
*/
|
||||
+ (BOOL)asyncLoadDataFromPath:(NSString *)path callback:(void(^)(NSObject *data))callback;
|
||||
|
||||
/** @name 写入 */
|
||||
/**
|
||||
存储数据到本地
|
||||
@param path 文件路径
|
||||
@param data 需要存储的数据
|
||||
@return NSData 文件中的数据
|
||||
*/
|
||||
+ (BOOL)saveData:(NSObject *)data withPath:(NSString *)path;
|
||||
|
||||
/**
|
||||
异步存储数据到本地
|
||||
@param path 文件路径
|
||||
@param data 需要存储的数据
|
||||
@param callback 存储完成后回调
|
||||
*/
|
||||
+ (void)asyncSaveData:(NSObject *)data withPath:(NSString *)path callback:(void(^)(BOOL succeed))callback;
|
||||
|
||||
|
||||
/**
|
||||
存储数据到本地
|
||||
@param path 文件路径
|
||||
@param data 需要存储的数据
|
||||
@param fileName 文件名
|
||||
@return NSData 文件中的数据
|
||||
*/
|
||||
+ (BOOL)saveData:(NSObject *)data withPath:(NSString *)path fileName:(NSString *)fileName;
|
||||
|
||||
|
||||
/**
|
||||
异步存储数据到本地
|
||||
@param path 文件路径
|
||||
@param data 需要存储的数据
|
||||
@param fileName 文件名
|
||||
@param callback 完成后的回调
|
||||
*/
|
||||
+ (void)asyncSaveData:(NSObject *)data
|
||||
withPath:(NSString *)path
|
||||
fileName:(NSString *)fileName
|
||||
callback:(void(^)(BOOL succeed))callback;
|
||||
|
||||
/** @name 删除 */
|
||||
/**
|
||||
删除文件
|
||||
@param path 文件路径
|
||||
@return 是否删除成功
|
||||
*/
|
||||
+ (BOOL)removeFileAtPath:(NSString *)path;
|
||||
|
||||
/**
|
||||
删除文件目录和目录下的所有文件
|
||||
@param path 文件目录路径
|
||||
@param condition 文件删除条件判断
|
||||
*/
|
||||
+ (void)removeFileAtPath:(NSString *)path condition:(BOOL (^)(NSDictionary *fileInfo))condition;
|
||||
|
||||
/**
|
||||
删除文件目录和目录下的所有文件
|
||||
@param path 文件目录路径
|
||||
@param condition 文件删除条件判断
|
||||
*/
|
||||
+ (void)asyncRemoveFileAtPath:(NSString *)path condition:(BOOL (^)(NSDictionary *fileInfo))condition;
|
||||
|
||||
|
||||
/** @name 其他 */
|
||||
/**
|
||||
判断该路径是否有文件
|
||||
@param path 文件路径
|
||||
@return BOOL 是否有文件存在
|
||||
*/
|
||||
+ (BOOL)fileExistsAtPath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
@interface TYFileManager (TYPahtHelper)
|
||||
|
||||
+ (BOOL)createPathIfNecessary:(NSString*)path;
|
||||
|
||||
+ (NSString*)documentDirectoryPath;
|
||||
|
||||
+ (NSString*)documentDirectoryPathWithName:(NSString*)name;
|
||||
|
||||
+ (NSString*)cacheDirectoryPathWithName:(NSString*)name;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa3a9f8eecab249f481453b2d1a52d6d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// GTMBase64.h
|
||||
//
|
||||
// Copyright 2006-2008 Google 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
|
||||
// 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.
|
||||
//
|
||||
|
||||
|
||||
// WARNING: This class provides a subset of the functionality available in
|
||||
// GTMStringEncoding and may go away in the future.
|
||||
// Please consider using GTMStringEncoding instead.
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
// GTMBase64
|
||||
//
|
||||
/// Helper for handling Base64 and WebSafeBase64 encodings
|
||||
//
|
||||
/// The webSafe methods use different character set and also the results aren't
|
||||
/// always padded to a multiple of 4 characters. This is done so the resulting
|
||||
/// data can be used in urls and url query arguments without needing any
|
||||
/// encoding. You must use the webSafe* methods together, the data does not
|
||||
/// interop with the RFC methods.
|
||||
//
|
||||
@interface TYGTMBase64 : NSObject
|
||||
|
||||
//
|
||||
// Standard Base64 (RFC) handling
|
||||
//
|
||||
|
||||
// encodeData:
|
||||
//
|
||||
/// Base64 encodes contents of the NSData object.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)encodeData:(NSData *)data;
|
||||
|
||||
// decodeData:
|
||||
//
|
||||
/// Base64 decodes contents of the NSData object.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the decoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)decodeData:(NSData *)data;
|
||||
|
||||
// encodeBytes:length:
|
||||
//
|
||||
/// Base64 encodes the data pointed at by |bytes|.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)encodeBytes:(const void *)bytes length:(NSUInteger)length;
|
||||
|
||||
// decodeBytes:length:
|
||||
//
|
||||
/// Base64 decodes the data pointed at by |bytes|.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)decodeBytes:(const void *)bytes length:(NSUInteger)length;
|
||||
|
||||
// stringByEncodingData:
|
||||
//
|
||||
/// Base64 encodes contents of the NSData object.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSString with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSString *)stringByEncodingData:(NSData *)data;
|
||||
|
||||
// stringByEncodingBytes:length:
|
||||
//
|
||||
/// Base64 encodes the data pointed at by |bytes|.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSString with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSString *)stringByEncodingBytes:(const void *)bytes length:(NSUInteger)length;
|
||||
|
||||
// decodeString:
|
||||
//
|
||||
/// Base64 decodes contents of the NSString.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the decoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)decodeString:(NSString *)string;
|
||||
|
||||
//
|
||||
// Modified Base64 encoding so the results can go onto urls.
|
||||
//
|
||||
// The changes are in the characters generated and also allows the result to
|
||||
// not be padded to a multiple of 4.
|
||||
// Must use the matching call to encode/decode, won't interop with the
|
||||
// RFC versions.
|
||||
//
|
||||
|
||||
// webSafeEncodeData:padded:
|
||||
//
|
||||
/// WebSafe Base64 encodes contents of the NSData object. If |padded| is YES
|
||||
/// then padding characters are added so the result length is a multiple of 4.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)webSafeEncodeData:(NSData *)data
|
||||
padded:(BOOL)padded;
|
||||
|
||||
// webSafeDecodeData:
|
||||
//
|
||||
/// WebSafe Base64 decodes contents of the NSData object.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the decoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)webSafeDecodeData:(NSData *)data;
|
||||
|
||||
// webSafeEncodeBytes:length:padded:
|
||||
//
|
||||
/// WebSafe Base64 encodes the data pointed at by |bytes|. If |padded| is YES
|
||||
/// then padding characters are added so the result length is a multiple of 4.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)webSafeEncodeBytes:(const void *)bytes
|
||||
length:(NSUInteger)length
|
||||
padded:(BOOL)padded;
|
||||
|
||||
// webSafeDecodeBytes:length:
|
||||
//
|
||||
/// WebSafe Base64 decodes the data pointed at by |bytes|.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)webSafeDecodeBytes:(const void *)bytes length:(NSUInteger)length;
|
||||
|
||||
// stringByWebSafeEncodingData:padded:
|
||||
//
|
||||
/// WebSafe Base64 encodes contents of the NSData object. If |padded| is YES
|
||||
/// then padding characters are added so the result length is a multiple of 4.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSString with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSString *)stringByWebSafeEncodingData:(NSData *)data
|
||||
padded:(BOOL)padded;
|
||||
|
||||
// stringByWebSafeEncodingBytes:length:padded:
|
||||
//
|
||||
/// WebSafe Base64 encodes the data pointed at by |bytes|. If |padded| is YES
|
||||
/// then padding characters are added so the result length is a multiple of 4.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSString with the encoded payload. nil for any error.
|
||||
//
|
||||
+(NSString *)stringByWebSafeEncodingBytes:(const void *)bytes
|
||||
length:(NSUInteger)length
|
||||
padded:(BOOL)padded;
|
||||
|
||||
// webSafeDecodeString:
|
||||
//
|
||||
/// WebSafe Base64 decodes contents of the NSString.
|
||||
//
|
||||
/// Returns:
|
||||
/// A new autoreleased NSData with the decoded payload. nil for any error.
|
||||
//
|
||||
+(NSData *)webSafeDecodeString:(NSString *)string;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d97b8d8735e7543529d4a0a3149bbfb0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TYGetUA.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 周翔宇 on 2019/11/13.
|
||||
// Copyright © 2019 刘磊. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYGetUA : NSObject
|
||||
@property (nonatomic,copy) NSString *userAgrntString;
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
-(void)getUserAgent;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfa26189637ce4ae6828557a207a8eda
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,285 @@
|
||||
// TYHTTPSessionManager.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#if !TARGET_OS_WATCH
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
#endif
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
#import "TYURLSessionManager.h"
|
||||
|
||||
/**
|
||||
`TYHTTPSessionManager` is a subclass of `TYURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
|
||||
|
||||
## Subclassing Notes
|
||||
|
||||
Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `TYHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
|
||||
|
||||
## Methods to Override
|
||||
|
||||
To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:`.
|
||||
|
||||
## Serialization
|
||||
|
||||
Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<TYURLRequestSerialization>`.
|
||||
|
||||
Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<TYURLResponseSerialization>`
|
||||
|
||||
## URL Construction Using Relative Paths
|
||||
|
||||
For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`.
|
||||
|
||||
Below are a few examples of how `baseURL` and relative paths interact:
|
||||
|
||||
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
|
||||
[NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
|
||||
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
|
||||
[NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
|
||||
[NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
|
||||
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
|
||||
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
|
||||
|
||||
Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
|
||||
|
||||
@warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
|
||||
*/
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYHTTPSessionManager : TYURLSessionManager <NSSecureCoding, NSCopying>
|
||||
|
||||
/**
|
||||
The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
|
||||
|
||||
/**
|
||||
Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `TYHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies.
|
||||
|
||||
@warning `requestSerializer` must not be `nil`.
|
||||
*/
|
||||
@property (nonatomic, strong) TYHTTPRequestSerializer <TYURLRequestSerialization> * requestSerializer;
|
||||
|
||||
/**
|
||||
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `TYJSONResponseSerializer`.
|
||||
|
||||
@warning `responseSerializer` must not be `nil`.
|
||||
*/
|
||||
@property (nonatomic, strong) TYHTTPResponseSerializer <TYURLResponseSerialization> * responseSerializer;
|
||||
|
||||
///-------------------------------
|
||||
/// @name Managing Security Policy
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
The security policy used by created session to evaluate server trust for secure connections. `TYURLSessionManager` uses the `defaultPolicy` unless otherwise specified. A security policy configured with `TYSSLPinningModePublicKey` or `TYSSLPinningModeCertificate` can only be applied on a session manager initialized with a secure base URL (i.e. https). Applying a security policy with pinning enabled on an insecure session manager throws an `Invalid Security Policy` exception.
|
||||
*/
|
||||
@property (nonatomic, strong) TYSecurityPolicy *securityPolicy;
|
||||
|
||||
///---------------------
|
||||
/// @name Initialization
|
||||
///---------------------
|
||||
|
||||
/**
|
||||
Creates and returns an `TYHTTPSessionManager` object.
|
||||
*/
|
||||
+ (instancetype)manager;
|
||||
|
||||
/**
|
||||
Initializes an `TYHTTPSessionManager` object with the specified base URL.
|
||||
|
||||
@param url The base URL for the HTTP client.
|
||||
|
||||
@return The newly-initialized HTTP client
|
||||
*/
|
||||
- (instancetype)initWithBaseURL:(nullable NSURL *)url;
|
||||
|
||||
/**
|
||||
Initializes an `TYHTTPSessionManager` object with the specified base URL.
|
||||
|
||||
This is the designated initializer.
|
||||
|
||||
@param url The base URL for the HTTP client.
|
||||
@param configuration The configuration used to create the managed session.
|
||||
|
||||
@return The newly-initialized HTTP client
|
||||
*/
|
||||
- (instancetype)initWithBaseURL:(nullable NSURL *)url
|
||||
sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
///---------------------------
|
||||
/// @name Making HTTP Requests
|
||||
///---------------------------
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `GET` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `POST` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `TYMultipartFormData` protocol.
|
||||
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
constructingBodyWithBlock:(nullable void (^)(id <TYMultipartFormData> formData))block
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionDataTask` with a custom `HTTPMethod` request.
|
||||
|
||||
@param method The HTTPMethod string used to create the request.
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
|
||||
URLString:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2590a5c0e85cd4a488344deefe7468c0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// TYHttpHandle.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TYNetworking.h"
|
||||
#import "TYGetUA.h"
|
||||
#import "TYEncrypt.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
static TYHTTPSessionManager *_httpManager;
|
||||
|
||||
@interface TYHttpHandle : NSObject
|
||||
|
||||
|
||||
|
||||
#pragma mark ---旧版网络框架
|
||||
//缺点: 不同SDK使用corekit的网络库时, URL为同一份变量, 不能满足不同SDK不同baseURL的需求
|
||||
|
||||
+ (TYHTTPSessionManager *)resetServerUrl:(NSString *)url;
|
||||
|
||||
|
||||
+ (NSString *)baseUrl;
|
||||
|
||||
+ (NSURLSessionDataTask *)md5RequestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
+ (NSURLSessionDataTask *)requestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
+ (NSURLSessionDataTask *)requestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
responseSerializer:(TYHTTPResponseSerializer *)responseSerializer
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
+ (NSURLSessionDataTask *)normalRequestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
+ (NSURLSessionDataTask *)normalRequestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
responseSerializer:(TYHTTPResponseSerializer *)responseSerializer
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2a7c6c6374ec49c3bcee3d28761983e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// TYHttpManager.h
|
||||
// TYSDKCoreKit
|
||||
//
|
||||
// Created by 史良 on 2021/6/15.
|
||||
// Copyright © 2021 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TYNetworking.h"
|
||||
#import "TYGetUA.h"
|
||||
#import "TYEncrypt.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** 请求类型 */
|
||||
typedef NS_ENUM(NSUInteger, TYRequestType) {
|
||||
Get = 0, /**< Get */
|
||||
Post = 1, /**< Post */
|
||||
};
|
||||
|
||||
@interface TYHttpManager : NSObject
|
||||
|
||||
#pragma mark - 更新网络框架
|
||||
|
||||
//每个网络工具对象可以持有不同的URL地址
|
||||
@property (nonatomic, copy) NSString * serverUrlStr;
|
||||
@property (nonatomic, strong) TYHTTPSessionManager * httpManager;
|
||||
|
||||
|
||||
/// 创建一个新的网络handle
|
||||
+ (TYHttpManager *)createHandleWithUrl:(NSString *)serverUrl;
|
||||
|
||||
- (NSURLSessionDataTask *)md5RequestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
- (NSURLSessionDataTask *)requestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
- (NSURLSessionDataTask *)requestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
responseSerializer:(TYHTTPResponseSerializer *)responseSerializer
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
- (NSURLSessionDataTask *)normalRequestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
- (NSURLSessionDataTask *)normalRequestWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
responseSerializer:(TYHTTPResponseSerializer *)responseSerializer
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
|
||||
|
||||
|
||||
- (NSURLSessionDataTask *)getInfoWithUrl:(NSString *)url
|
||||
parameters:(id)parameters
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
/// 网络请求
|
||||
/// @param type 请求类型
|
||||
/// @param headers 请求头参数
|
||||
/// @param parameters 请求体类型
|
||||
- (NSURLSessionDataTask *)requestWithUrl:(NSString *)url
|
||||
type:(TYRequestType)type
|
||||
headers:(id)headers
|
||||
parameters:(id)parameters
|
||||
responseSerializer:(TYHTTPResponseSerializer *)responseSerializer
|
||||
success:(void (^_Nullable)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject))success
|
||||
failure:(void (^_Nullable)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2092779fac25246d3bfd3318f3ac3c45
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// TYHttpResponse.h
|
||||
// TYSDKCoreKit
|
||||
//
|
||||
// Created by 史良 on 2022/3/25.
|
||||
// Copyright © 2022 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYHttpResponse : NSObject
|
||||
|
||||
|
||||
/// 快速判断 code=0为yes
|
||||
@property (nonatomic, assign, readonly, getter=isSuccess) BOOL success;
|
||||
|
||||
/// 业务处理结果 通常0成功
|
||||
@property (nonatomic, assign) int code;
|
||||
|
||||
/// 错误描述 优先取服务端info
|
||||
@property (nonatomic, copy) NSString * msg;
|
||||
|
||||
/// 返回内容
|
||||
@property (nonatomic, assign) id respObj;
|
||||
|
||||
/// 非200
|
||||
@property (nonatomic, assign) BOOL httpError;
|
||||
|
||||
|
||||
/// 创建返回层数据
|
||||
/// @param obj http返回的原始数据
|
||||
+ (TYHttpResponse *)createResponseWith:(id)obj;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d02b23c3c1f994b9bbea1d99b3dc09b8
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// TYKeychain.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
@interface TYKeychain : NSObject
|
||||
|
||||
+ (id)loadValueForKey:(NSString *)keyStr;
|
||||
+ (id)loadValueForKey:(NSString *)keyStr forAccessGroup:(NSString *)groupStr;
|
||||
|
||||
+ (BOOL)deleteValueForKey:(NSString *)keyStr;
|
||||
+ (BOOL)deleteValueForKey:(NSString *)keyStr forAccessGroup:(NSString *)groupStr;
|
||||
|
||||
+ (BOOL)saveValue:(id)value forKey:(NSString *)keyStr;
|
||||
+ (BOOL)saveValue:(id)value forKey:(NSString *)keyStr forAccessGroup:(NSString *)groupStr;
|
||||
|
||||
+ (NSString *)getBundleSeedID;
|
||||
|
||||
@end
|
||||
|
||||
@interface TYKeychain(TYPrivate)
|
||||
|
||||
+ (BOOL)save:(NSString *)keyStr data:(id)data;
|
||||
+ (BOOL)deleteForKey:(NSString *)keyStr;
|
||||
+ (id)load:(NSString *)keyStr;
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62b0bd499efb34cfca41a490bcc9d108
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// TYLogHelper.h
|
||||
// TYSDKCoreKit
|
||||
//
|
||||
// Created by Liang shi on 2021/2/4.
|
||||
// Copyright © 2021 刘磊. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TYBaseResp.h"
|
||||
|
||||
#define TYTerminalLogWithDesc(logKey, description) [TYLogHelper logWithFile:[NSString stringWithFormat:@"%s", __FILE_NAME__] func:[NSString stringWithFormat:@"%s", __func__] key:logKey desc:description];
|
||||
|
||||
#define TYTerminalLogWithResp(logKey, logResp) [TYLogHelper logWithFile:[NSString stringWithFormat:@"%s", __FILE_NAME__] func:[NSString stringWithFormat:@"%s", __func__] key:logKey resp:logResp]
|
||||
|
||||
#define TYTerminalLogInfoWithDesc(logDesc) [TYLogHelper logInfoWithFile:[NSString stringWithFormat:@"%s", __FILE_NAME__] func:[NSString stringWithFormat:@"%s", __func__] desc:logDesc]
|
||||
|
||||
#define TYTerminalLogInfoWithDesc(logDesc, ...) [TYLogHelper logInfoWithFile:[NSString stringWithFormat:@"%s", __FILE_NAME__] func:[NSString stringWithFormat:@"%s", __func__] desc:[NSString stringWithFormat:logDesc, ##__VA_ARGS__]]
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYLogHelper : NSObject
|
||||
|
||||
+ (void)checkTerminalLog:(BOOL)check;
|
||||
|
||||
/// 根据外界key读取预配置文案 格式化打印
|
||||
/// @param key 文案对应的key
|
||||
/// @param desc 使用外界传入的配置好的描述方案 如果传nil或空字符串,将使用默认的打印
|
||||
+ (void)logWithFile:(NSString *)currFile func:(NSString *)currFunc key:(NSString *)key desc:(NSString *)desc;
|
||||
|
||||
/// 根据外界key读取预配置文案 格式化打印
|
||||
/// @param key 文案对应的key
|
||||
/// @param resp 使用外界传入的错误信息
|
||||
+ (void)logWithFile:(NSString *)currFile func:(NSString *)currFunc key:(NSString *)key resp:(TYBaseResp *)resp;
|
||||
|
||||
/// 通用格式化打印
|
||||
+ (void)logInfoWithFile:(NSString *)currFile func:(NSString *)currFunc desc:(NSString *)desc;
|
||||
|
||||
/// 更新本地打印数据
|
||||
+ (void)updateLogDataSourceWith:(NSDictionary *)dic key:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a32695958d6243f497c75cef67557a2
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,216 @@
|
||||
// TYNetworkReachabilityManager.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if !TARGET_OS_WATCH
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, TYNetworkReachabilityStatus) {
|
||||
TYNetworkReachabilityStatusUnknown = -1,
|
||||
TYNetworkReachabilityStatusNotReachable = 0,
|
||||
TYNetworkReachabilityStatusReachableViaWWAN = 1,
|
||||
TYNetworkReachabilityStatusReachableViaWiFi = 2,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
`TYNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
|
||||
|
||||
Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
|
||||
|
||||
See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
|
||||
|
||||
@warning Instances of `TYNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
|
||||
*/
|
||||
@interface TYNetworkReachabilityManager : NSObject
|
||||
|
||||
/**
|
||||
The current network reachability status.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign) TYNetworkReachabilityStatus networkReachabilityStatus;
|
||||
|
||||
/**
|
||||
Whether or not the network is currently reachable.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
|
||||
|
||||
/**
|
||||
Whether or not the network is currently reachable via WWAN.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
|
||||
|
||||
/**
|
||||
Whether or not the network is currently reachable via WiFi.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
|
||||
|
||||
///---------------------
|
||||
/// @name Initialization
|
||||
///---------------------
|
||||
|
||||
/**
|
||||
Returns the shared network reachability manager.
|
||||
*/
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
/**
|
||||
Creates and returns a network reachability manager with the default socket address.
|
||||
|
||||
@return An initialized network reachability manager, actively monitoring the default socket address.
|
||||
*/
|
||||
+ (instancetype)manager;
|
||||
|
||||
/**
|
||||
Creates and returns a network reachability manager for the specified domain.
|
||||
|
||||
@param domain The domain used to evaluate network reachability.
|
||||
|
||||
@return An initialized network reachability manager, actively monitoring the specified domain.
|
||||
*/
|
||||
+ (instancetype)managerForDomain:(NSString *)domain;
|
||||
|
||||
/**
|
||||
Creates and returns a network reachability manager for the socket address.
|
||||
|
||||
@param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
|
||||
|
||||
@return An initialized network reachability manager, actively monitoring the specified socket address.
|
||||
*/
|
||||
+ (instancetype)managerForAddress:(const void *)address;
|
||||
|
||||
/**
|
||||
Initializes an instance of a network reachability manager from the specified reachability object.
|
||||
|
||||
@param reachability The reachability object to monitor.
|
||||
|
||||
@return An initialized network reachability manager, actively monitoring the specified reachability.
|
||||
*/
|
||||
- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Unavailable initializer
|
||||
*/
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* Unavailable initializer
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
///--------------------------------------------------
|
||||
/// @name Starting & Stopping Reachability Monitoring
|
||||
///--------------------------------------------------
|
||||
|
||||
/**
|
||||
Starts monitoring for changes in network reachability status.
|
||||
*/
|
||||
- (void)startMonitoring;
|
||||
|
||||
/**
|
||||
Stops monitoring for changes in network reachability status.
|
||||
*/
|
||||
- (void)stopMonitoring;
|
||||
|
||||
///-------------------------------------------------
|
||||
/// @name Getting Localized Reachability Description
|
||||
///-------------------------------------------------
|
||||
|
||||
/**
|
||||
Returns a localized string representation of the current network reachability status.
|
||||
*/
|
||||
- (NSString *)localizedNetworkReachabilityStatusString;
|
||||
|
||||
///---------------------------------------------------
|
||||
/// @name Setting Network Reachability Change Callback
|
||||
///---------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets a callback to be executed when the network availability of the `baseURL` host changes.
|
||||
|
||||
@param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
|
||||
*/
|
||||
- (void)setReachabilityStatusChangeBlock:(nullable void (^)(TYNetworkReachabilityStatus status))block;
|
||||
|
||||
@end
|
||||
|
||||
///----------------
|
||||
/// @name Constants
|
||||
///----------------
|
||||
|
||||
/**
|
||||
## Network Reachability
|
||||
|
||||
The following constants are provided by `TYNetworkReachabilityManager` as possible network reachability statuses.
|
||||
|
||||
enum {
|
||||
TYNetworkReachabilityStatusUnknown,
|
||||
TYNetworkReachabilityStatusNotReachable,
|
||||
TYNetworkReachabilityStatusReachableViaWWAN,
|
||||
TYNetworkReachabilityStatusReachableViaWiFi,
|
||||
}
|
||||
|
||||
`TYNetworkReachabilityStatusUnknown`
|
||||
The `baseURL` host reachability is not known.
|
||||
|
||||
`TYNetworkReachabilityStatusNotReachable`
|
||||
The `baseURL` host cannot be reached.
|
||||
|
||||
`TYNetworkReachabilityStatusReachableViaWWAN`
|
||||
The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
|
||||
|
||||
`TYNetworkReachabilityStatusReachableViaWiFi`
|
||||
The `baseURL` host can be reached via a Wi-Fi connection.
|
||||
|
||||
### Keys for Notification UserInfo Dictionary
|
||||
|
||||
Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
|
||||
|
||||
`TYNetworkingReachabilityNotificationStatusItem`
|
||||
A key in the userInfo dictionary in a `TYNetworkingReachabilityDidChangeNotification` notification.
|
||||
The corresponding value is an `NSNumber` object representing the `TYNetworkReachabilityStatus` value for the current reachability status.
|
||||
*/
|
||||
|
||||
///--------------------
|
||||
/// @name Notifications
|
||||
///--------------------
|
||||
|
||||
/**
|
||||
Posted when network reachability changes.
|
||||
This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `TYNetworkingReachabilityNotificationStatusItem` key, representing the `TYNetworkReachabilityStatus` value for the current network reachability.
|
||||
|
||||
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingReachabilityDidChangeNotification;
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingReachabilityNotificationStatusItem;
|
||||
|
||||
///--------------------
|
||||
/// @name Functions
|
||||
///--------------------
|
||||
|
||||
/**
|
||||
Returns a localized string representation of an `TYNetworkReachabilityStatus` value.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * TYStringFromNetworkReachabilityStatus(TYNetworkReachabilityStatus status);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c14f6c04c53945019315cd839698822
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
// TYNetworking.h
|
||||
//
|
||||
// Copyright (c) 2013 TYNetworking (http://TYNetworking.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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Availability.h>
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
#ifndef _TYNETWORKING_
|
||||
#define _TYNETWORKING_
|
||||
|
||||
#import "TYURLRequestSerialization.h"
|
||||
#import "TYURLResponseSerialization.h"
|
||||
#import "TYSecurityPolicy.h"
|
||||
|
||||
#if !TARGET_OS_WATCH
|
||||
#import "TYNetworkReachabilityManager.h"
|
||||
#endif
|
||||
|
||||
#import "TYURLSessionManager.h"
|
||||
#import "TYHTTPSessionManager.h"
|
||||
|
||||
#endif /* _TYNETWORKING_ */
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ddb44856927a4993bec73cf157d301f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright (c) 2011, Tony Million.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted 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.
|
||||
|
||||
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 HOLDER 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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
|
||||
//! Project version number for MacOSReachability.
|
||||
FOUNDATION_EXPORT double TYReachabilityVersionNumber;
|
||||
|
||||
//! Project version string for MacOSReachability.
|
||||
FOUNDATION_EXPORT const unsigned char TYReachabilityVersionString[];
|
||||
|
||||
/**
|
||||
* Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
|
||||
*
|
||||
* @see http://nshipster.com/ns_enum-ns_options/
|
||||
**/
|
||||
#ifndef NS_ENUM
|
||||
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
|
||||
#endif
|
||||
|
||||
extern NSString *const kTYReachabilityChangedNotification;
|
||||
|
||||
typedef NS_ENUM(NSInteger, NetworkStatus) {
|
||||
// Apple NetworkStatus Compatible Names.
|
||||
NotReachable = 0,
|
||||
ReachableViaWiFi = 2,
|
||||
ReachableViaWWAN = 1
|
||||
};
|
||||
|
||||
@class TYReachability;
|
||||
|
||||
typedef void (^NetworkReachable)(TYReachability * TYReachability);
|
||||
typedef void (^NetworkUnreachable)(TYReachability * TYReachability);
|
||||
typedef void (^NetworkReachability)(TYReachability * TYReachability, SCNetworkConnectionFlags flags);
|
||||
|
||||
|
||||
@interface TYReachability : NSObject
|
||||
|
||||
@property (nonatomic, copy) NetworkReachable reachableBlock;
|
||||
@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
|
||||
@property (nonatomic, copy) NetworkReachability TYReachabilityBlock;
|
||||
|
||||
@property (nonatomic, assign) BOOL reachableOnWWAN;
|
||||
|
||||
|
||||
+(instancetype)TYReachabilityWithHostname:(NSString*)hostname;
|
||||
// This is identical to the function above, but is here to maintain
|
||||
//compatibility with Apples original code. (see .m)
|
||||
+(instancetype)TYReachabilityWithHostName:(NSString*)hostname;
|
||||
+(instancetype)TYReachabilityForInternetConnection;
|
||||
+(instancetype)TYReachabilityWithAddress:(void *)hostAddress;
|
||||
+(instancetype)TYReachabilityForLocalWiFi;
|
||||
|
||||
-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
|
||||
|
||||
-(BOOL)startNotifier;
|
||||
-(void)stopNotifier;
|
||||
|
||||
-(BOOL)isReachable;
|
||||
-(BOOL)isReachableViaWWAN;
|
||||
-(BOOL)isReachableViaWiFi;
|
||||
|
||||
// WWAN may be available, but not active until a connection has been established.
|
||||
// WiFi may require a connection for VPN on Demand.
|
||||
-(BOOL)isConnectionRequired; // Identical DDG variant.
|
||||
-(BOOL)connectionRequired; // Apple's routine.
|
||||
// Dynamic, on demand connection?
|
||||
-(BOOL)isConnectionOnDemand;
|
||||
// Is user intervention required?
|
||||
-(BOOL)isInterventionRequired;
|
||||
|
||||
-(NetworkStatus)currentReachabilityStatus;
|
||||
-(SCNetworkReachabilityFlags)TYReachabilityFlags;
|
||||
-(NSString*)currentReachabilityString;
|
||||
-(NSString*)currentReachabilityFlags;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5f0698a1c616478eae785b9b8dbb71e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
// TYUtilsHandel.h
|
||||
// UtilsHandle
|
||||
//
|
||||
// Created by hui on 2021/2/20.
|
||||
// Copyright © 2021 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef TYUtilsHandel_h
|
||||
#define TYUtilsHandel_h
|
||||
|
||||
#import <TYSDKCoreKit/TYHttpHandle.h>
|
||||
#import <TYSDKCoreKit/TYUUID.h>
|
||||
#import <TYSDKCoreKit/TYKeychain.h>
|
||||
#import <TYSDKCoreKit/TYBaseResp.h>
|
||||
#import <TYSDKCoreKit/TYUtils.h>
|
||||
#import <TYSDKCoreKit/TYCoreHttpStatus.h>
|
||||
#import <TYSDKCoreKit/TYUpLoadImage.h>
|
||||
#import <TYSDKCoreKit/UIImage+TYProject.h>
|
||||
#import <TYSDKCoreKit/NSString+TYProject.h>
|
||||
#import <TYSDKCoreKit/NSObject+TYModelToDict.h>
|
||||
#import <TYSDKCoreKit/TYLogHelper.h>
|
||||
|
||||
// 用于定义所以渠道和SDK可能需要用到的事件
|
||||
#define XYSDKLoginSuccessWithUserInfo @"XYSDKLoginSuccessWithUserInfo"
|
||||
#define XYSDKRegisteSuccessWithUserInfo @"XYSDKRegisteSuccessWithUserInfo"
|
||||
#define XYSDKLoginProcessCompleted @"LoginProcessCompleted"
|
||||
#define NotifyAttributionDataReporting @"NotifyAttributionDataReporting"
|
||||
|
||||
#endif /* TYUtilsHandel_h */
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ef17f3ec5e564a6ba8dc62699920f1d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,161 @@
|
||||
// TYSecurityPolicy.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Security/Security.h>
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TYSSLPinningMode) {
|
||||
TYSSLPinningModeNone,
|
||||
TYSSLPinningModePublicKey,
|
||||
TYSSLPinningModeCertificate,
|
||||
};
|
||||
|
||||
/**
|
||||
`TYSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
|
||||
|
||||
Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
|
||||
*/
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
|
||||
|
||||
/**
|
||||
The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `TYSSLPinningModeNone`.
|
||||
*/
|
||||
@property (readonly, nonatomic, assign) TYSSLPinningMode SSLPinningMode;
|
||||
|
||||
/**
|
||||
The certificates used to evaluate server trust according to the SSL pinning mode.
|
||||
|
||||
Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
|
||||
|
||||
@see policyWithPinningMode:withPinnedCertificates:
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSSet <NSData *> *pinnedCertificates;
|
||||
|
||||
/**
|
||||
Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL allowInvalidCertificates;
|
||||
|
||||
/**
|
||||
Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL validatesDomainName;
|
||||
|
||||
///-----------------------------------------
|
||||
/// @name Getting Certificates from the Bundle
|
||||
///-----------------------------------------
|
||||
|
||||
/**
|
||||
Returns any certificates included in the bundle. If you are using TYNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
||||
|
||||
@return The certificates included in the given bundle.
|
||||
*/
|
||||
+ (NSSet <NSData *> *)certificatesInBundle:(NSBundle *)bundle;
|
||||
|
||||
///-----------------------------------------
|
||||
/// @name Getting Specific Security Policies
|
||||
///-----------------------------------------
|
||||
|
||||
/**
|
||||
Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
|
||||
|
||||
@return The default security policy.
|
||||
*/
|
||||
+ (instancetype)defaultPolicy;
|
||||
|
||||
///---------------------
|
||||
/// @name Initialization
|
||||
///---------------------
|
||||
|
||||
/**
|
||||
Creates and returns a security policy with the specified pinning mode.
|
||||
|
||||
Certificates with the `.cer` extension found in the main bundle will be pinned. If you want more control over which certificates are pinned, please use `policyWithPinningMode:withPinnedCertificates:` instead.
|
||||
|
||||
@param pinningMode The SSL pinning mode.
|
||||
|
||||
@return A new security policy.
|
||||
|
||||
@see -policyWithPinningMode:withPinnedCertificates:
|
||||
*/
|
||||
+ (instancetype)policyWithPinningMode:(TYSSLPinningMode)pinningMode;
|
||||
|
||||
/**
|
||||
Creates and returns a security policy with the specified pinning mode.
|
||||
|
||||
@param pinningMode The SSL pinning mode.
|
||||
@param pinnedCertificates The certificates to pin against.
|
||||
|
||||
@return A new security policy.
|
||||
|
||||
@see +certificatesInBundle:
|
||||
@see -pinnedCertificates
|
||||
*/
|
||||
+ (instancetype)policyWithPinningMode:(TYSSLPinningMode)pinningMode withPinnedCertificates:(NSSet <NSData *> *)pinnedCertificates;
|
||||
|
||||
///------------------------------
|
||||
/// @name Evaluating Server Trust
|
||||
///------------------------------
|
||||
|
||||
/**
|
||||
Whether or not the specified server trust should be accepted, based on the security policy.
|
||||
|
||||
This method should be used when responding to an authentication challenge from a server.
|
||||
|
||||
@param serverTrust The X.509 certificate trust of the server.
|
||||
@param domain The domain of serverTrust. If `nil`, the domain will not be validated.
|
||||
|
||||
@return Whether or not to trust the server.
|
||||
*/
|
||||
- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
|
||||
forDomain:(nullable NSString *)domain;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
///----------------
|
||||
/// @name Constants
|
||||
///----------------
|
||||
|
||||
/**
|
||||
## SSL Pinning Modes
|
||||
|
||||
The following constants are provided by `TYSSLPinningMode` as possible SSL pinning modes.
|
||||
|
||||
enum {
|
||||
TYSSLPinningModeNone,
|
||||
TYSSLPinningModePublicKey,
|
||||
TYSSLPinningModeCertificate,
|
||||
}
|
||||
|
||||
`TYSSLPinningModeNone`
|
||||
Do not used pinned certificates to validate servers.
|
||||
|
||||
`TYSSLPinningModePublicKey`
|
||||
Validate host certificates against public keys of pinned certificates.
|
||||
|
||||
`TYSSLPinningModeCertificate`
|
||||
Validate host certificates against pinned certificates.
|
||||
*/
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbb6cb5e88dfb428d944f984486ed7f9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,480 @@
|
||||
// TYURLRequestSerialization.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||
#import <UIKit/UIKit.h>
|
||||
#elif TARGET_OS_WATCH
|
||||
#import <WatchKit/WatchKit.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Returns a percent-escaped string following RFC 3986 for a query string key or value.
|
||||
RFC 3986 states that the following characters are "reserved" characters.
|
||||
- General Delimiters: ":", "#", "[", "]", "@", "?", "/"
|
||||
- Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
|
||||
|
||||
In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
|
||||
query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
|
||||
should be percent-escaped in the query string.
|
||||
|
||||
@param string The string to be percent-escaped.
|
||||
|
||||
@return The percent-escaped string.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * TYPercentEscapedStringFromString(NSString *string);
|
||||
|
||||
/**
|
||||
A helper method to generate encoded url query parameters for appending to the end of a URL.
|
||||
|
||||
@param parameters A dictionary of key/values to be encoded.
|
||||
|
||||
@return A url encoded query string
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * TYQueryStringFromParameters(NSDictionary *parameters);
|
||||
|
||||
/**
|
||||
The `TYURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
|
||||
|
||||
For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
|
||||
*/
|
||||
@protocol TYURLRequestSerialization <NSObject, NSSecureCoding, NSCopying>
|
||||
|
||||
/**
|
||||
Returns a request with the specified parameters encoded into a copy of the original request.
|
||||
|
||||
@param request The original request.
|
||||
@param parameters The parameters to be encoded.
|
||||
@param error The error that occurred while attempting to encode the request parameters.
|
||||
|
||||
@return A serialized request.
|
||||
*/
|
||||
- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||
withParameters:(nullable id)parameters
|
||||
error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, TYHTTPRequestQueryStringSerializationStyle) {
|
||||
TYHTTPRequestQueryStringDefaultStyle = 0,
|
||||
TYHTTPRequestQueryStringJsonStyle = 1,
|
||||
};
|
||||
|
||||
@protocol TYMultipartFormData;
|
||||
|
||||
/**
|
||||
`TYHTTPRequestSerializer` conforms to the `TYURLRequestSerialization` & `TYURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
||||
|
||||
Any request or response serializer dealing with HTTP is encouraged to subclass `TYHTTPRequestSerializer` in order to ensure consistent default behavior.
|
||||
*/
|
||||
@interface TYHTTPRequestSerializer : NSObject <TYURLRequestSerialization>
|
||||
|
||||
/**
|
||||
The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
|
||||
*/
|
||||
@property (nonatomic, assign) NSStringEncoding stringEncoding;
|
||||
|
||||
/**
|
||||
Whether created requests can use the device’s cellular radio (if present). `YES` by default.
|
||||
|
||||
@see NSMutableURLRequest -setAllowsCellularAccess:
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL allowsCellularAccess;
|
||||
|
||||
/**
|
||||
The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default.
|
||||
|
||||
@see NSMutableURLRequest -setCachePolicy:
|
||||
*/
|
||||
@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
|
||||
|
||||
/**
|
||||
Whether created requests should use the default cookie handling. `YES` by default.
|
||||
|
||||
@see NSMutableURLRequest -setHTTPShouldHandleCookies:
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL HTTPShouldHandleCookies;
|
||||
|
||||
/**
|
||||
Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default
|
||||
|
||||
@see NSMutableURLRequest -setHTTPShouldUsePipelining:
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL HTTPShouldUsePipelining;
|
||||
|
||||
/**
|
||||
The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default.
|
||||
|
||||
@see NSMutableURLRequest -setNetworkServiceType:
|
||||
*/
|
||||
@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType;
|
||||
|
||||
/**
|
||||
The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds.
|
||||
|
||||
@see NSMutableURLRequest -setTimeoutInterval:
|
||||
*/
|
||||
@property (nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||
|
||||
///---------------------------------------
|
||||
/// @name Configuring HTTP Request Headers
|
||||
///---------------------------------------
|
||||
|
||||
/**
|
||||
Default HTTP header field values to be applied to serialized requests. By default, these include the following:
|
||||
|
||||
- `Accept-Language` with the contents of `NSLocale +preferredLanguages`
|
||||
- `User-Agent` with the contents of various bundle identifiers and OS designations
|
||||
|
||||
@discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSDictionary <NSString *, NSString *> *HTTPRequestHeaders;
|
||||
|
||||
/**
|
||||
Creates and returns a serializer with default configuration.
|
||||
*/
|
||||
+ (instancetype)serializer;
|
||||
|
||||
/**
|
||||
Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
|
||||
|
||||
@param field The HTTP header to set a default value for
|
||||
@param value The value set as default for the specified header, or `nil`
|
||||
*/
|
||||
- (void)setValue:(nullable NSString *)value
|
||||
forHTTPHeaderField:(NSString *)field;
|
||||
|
||||
/**
|
||||
Returns the value for the HTTP headers set in the request serializer.
|
||||
|
||||
@param field The HTTP header to retrieve the default value for
|
||||
|
||||
@return The value set as default for the specified header, or `nil`
|
||||
*/
|
||||
- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field;
|
||||
|
||||
/**
|
||||
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
|
||||
|
||||
@param username The HTTP basic auth username
|
||||
@param password The HTTP basic auth password
|
||||
*/
|
||||
- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
|
||||
password:(NSString *)password;
|
||||
|
||||
/**
|
||||
Clears any existing value for the "Authorization" HTTP header.
|
||||
*/
|
||||
- (void)clearAuthorizationHeader;
|
||||
|
||||
///-------------------------------------------------------
|
||||
/// @name Configuring Query String Parameter Serialization
|
||||
///-------------------------------------------------------
|
||||
|
||||
/**
|
||||
HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default.
|
||||
*/
|
||||
@property (nonatomic, strong) NSSet <NSString *> *HTTPMethodsEncodingParametersInURI;
|
||||
|
||||
/**
|
||||
Set the method of query string serialization according to one of the pre-defined styles.
|
||||
|
||||
@param style The serialization style.
|
||||
|
||||
@see TYHTTPRequestQueryStringSerializationStyle
|
||||
*/
|
||||
- (void)setQueryStringSerializationWithStyle:(TYHTTPRequestQueryStringSerializationStyle)style;
|
||||
|
||||
/**
|
||||
Set the a custom method of query string serialization according to the specified block.
|
||||
|
||||
@param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request.
|
||||
*/
|
||||
- (void)setQueryStringSerializationWithBlock:(nullable NSString * _Nullable (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block;
|
||||
|
||||
///-------------------------------
|
||||
/// @name Creating Request Objects
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string.
|
||||
|
||||
If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
|
||||
|
||||
@param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
|
||||
@param error The error that occurred while constructing the request.
|
||||
|
||||
@return An `NSMutableURLRequest` object.
|
||||
*/
|
||||
- (nullable NSMutableURLRequest *)requestWithMethod:(NSString *)method
|
||||
URLString:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
error:(NSError * _Nullable __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
|
||||
|
||||
Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
|
||||
|
||||
@param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded and set in the request HTTP body.
|
||||
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `TYMultipartFormData` protocol.
|
||||
@param error The error that occurred while constructing the request.
|
||||
|
||||
@return An `NSMutableURLRequest` object
|
||||
*/
|
||||
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
|
||||
URLString:(NSString *)URLString
|
||||
parameters:(nullable NSDictionary <NSString *, id> *)parameters
|
||||
constructingBodyWithBlock:(nullable void (^)(id <TYMultipartFormData> formData))block
|
||||
error:(NSError * _Nullable __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished.
|
||||
|
||||
@param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`.
|
||||
@param fileURL The file URL to write multipart form contents to.
|
||||
@param handler A handler block to execute.
|
||||
|
||||
@discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `TYURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
|
||||
|
||||
@see https://github.com/TYNetworking/TYNetworking/issues/1398
|
||||
*/
|
||||
- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
|
||||
writingStreamContentsToFile:(NSURL *)fileURL
|
||||
completionHandler:(nullable void (^)(NSError * _Nullable error))handler;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
The `TYMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `TYHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`.
|
||||
*/
|
||||
@protocol TYMultipartFormData
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||
|
||||
The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
|
||||
|
||||
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||
|
||||
@return `YES` if the file data was successfully appended, otherwise `NO`.
|
||||
*/
|
||||
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
||||
name:(NSString *)name
|
||||
error:(NSError * _Nullable __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||
|
||||
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
|
||||
@param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
|
||||
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||
|
||||
@return `YES` if the file data was successfully appended otherwise `NO`.
|
||||
*/
|
||||
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
mimeType:(NSString *)mimeType
|
||||
error:(NSError * _Nullable __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
|
||||
|
||||
@param inputStream The input stream to be appended to the form data
|
||||
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
|
||||
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
|
||||
@param length The length of the specified input stream in bytes.
|
||||
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||
*/
|
||||
- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
length:(int64_t)length
|
||||
mimeType:(NSString *)mimeType;
|
||||
|
||||
/**
|
||||
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||
|
||||
@param data The data to be encoded and appended to the form data.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||
*/
|
||||
- (void)appendPartWithFileData:(NSData *)data
|
||||
name:(NSString *)name
|
||||
fileName:(NSString *)fileName
|
||||
mimeType:(NSString *)mimeType;
|
||||
|
||||
/**
|
||||
Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
|
||||
|
||||
@param data The data to be encoded and appended to the form data.
|
||||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
*/
|
||||
|
||||
- (void)appendPartWithFormData:(NSData *)data
|
||||
name:(NSString *)name;
|
||||
|
||||
|
||||
/**
|
||||
Appends HTTP headers, followed by the encoded data and the multipart form boundary.
|
||||
|
||||
@param headers The HTTP headers to be appended to the form data.
|
||||
@param body The data to be encoded and appended to the form data. This parameter must not be `nil`.
|
||||
*/
|
||||
- (void)appendPartWithHeaders:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
body:(NSData *)body;
|
||||
|
||||
/**
|
||||
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
|
||||
|
||||
When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kTYUploadStream3GSuggestedPacketSize` and `kTYUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
|
||||
|
||||
@param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb.
|
||||
@param delay Duration of delay each time a packet is read. By default, no delay is set.
|
||||
*/
|
||||
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
|
||||
delay:(NSTimeInterval)delay;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYJSONRequestSerializer` is a subclass of `TYHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
|
||||
*/
|
||||
@interface TYJSONRequestSerializer : TYHTTPRequestSerializer
|
||||
|
||||
/**
|
||||
Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default.
|
||||
*/
|
||||
@property (nonatomic, assign) NSJSONWritingOptions writingOptions;
|
||||
|
||||
/**
|
||||
Creates and returns a JSON serializer with specified reading and writing options.
|
||||
|
||||
@param writingOptions The specified JSON writing options.
|
||||
*/
|
||||
+ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYPropertyListRequestSerializer` is a subclass of `TYHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`.
|
||||
*/
|
||||
@interface TYPropertyListRequestSerializer : TYHTTPRequestSerializer
|
||||
|
||||
/**
|
||||
The property list format. Possible values are described in "NSPropertyListFormat".
|
||||
*/
|
||||
@property (nonatomic, assign) NSPropertyListFormat format;
|
||||
|
||||
/**
|
||||
@warning The `writeOptions` property is currently unused.
|
||||
*/
|
||||
@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions;
|
||||
|
||||
/**
|
||||
Creates and returns a property list serializer with a specified format, read options, and write options.
|
||||
|
||||
@param format The property list format.
|
||||
@param writeOptions The property list write options.
|
||||
|
||||
@warning The `writeOptions` property is currently unused.
|
||||
*/
|
||||
+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
|
||||
writeOptions:(NSPropertyListWriteOptions)writeOptions;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
///----------------
|
||||
/// @name Constants
|
||||
///----------------
|
||||
|
||||
/**
|
||||
## Error Domains
|
||||
|
||||
The following error domain is predefined.
|
||||
|
||||
- `NSString * const TYURLRequestSerializationErrorDomain`
|
||||
|
||||
### Constants
|
||||
|
||||
`TYURLRequestSerializationErrorDomain`
|
||||
TYURLRequestSerializer errors. Error codes for `TYURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYURLRequestSerializationErrorDomain;
|
||||
|
||||
/**
|
||||
## User info dictionary keys
|
||||
|
||||
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||
|
||||
- `NSString * const TYNetworkingOperationFailingURLRequestErrorKey`
|
||||
|
||||
### Constants
|
||||
|
||||
`TYNetworkingOperationFailingURLRequestErrorKey`
|
||||
The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `TYURLRequestSerializationErrorDomain`.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingOperationFailingURLRequestErrorKey;
|
||||
|
||||
/**
|
||||
## Throttling Bandwidth for HTTP Request Input Streams
|
||||
|
||||
@see -throttleBandwidthWithPacketSize:delay:
|
||||
|
||||
### Constants
|
||||
|
||||
`kTYUploadStream3GSuggestedPacketSize`
|
||||
Maximum packet size, in number of bytes. Equal to 16kb.
|
||||
|
||||
`kTYUploadStream3GSuggestedDelay`
|
||||
Duration of delay each time a packet is read. Equal to 0.2 seconds.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSUInteger const kTYUploadStream3GSuggestedPacketSize;
|
||||
FOUNDATION_EXPORT NSTimeInterval const kTYUploadStream3GSuggestedDelay;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f96d17d2acb334b01b52d0ecde033255
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,313 @@
|
||||
// TYURLResponseSerialization.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Recursively removes `NSNull` values from a JSON object.
|
||||
*/
|
||||
FOUNDATION_EXPORT id TYJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions);
|
||||
|
||||
/**
|
||||
The `TYURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
|
||||
|
||||
For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
|
||||
*/
|
||||
@protocol TYURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
|
||||
|
||||
/**
|
||||
The response object decoded from the data associated with a specified response.
|
||||
|
||||
@param response The response to be processed.
|
||||
@param data The response data to be decoded.
|
||||
@param error The error that occurred while attempting to decode the response data.
|
||||
|
||||
@return The object decoded from the specified response data.
|
||||
*/
|
||||
- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
|
||||
data:(nullable NSData *)data
|
||||
error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYHTTPResponseSerializer` conforms to the `TYURLRequestSerialization` & `TYURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
||||
|
||||
Any request or response serializer dealing with HTTP is encouraged to subclass `TYHTTPResponseSerializer` in order to ensure consistent default behavior.
|
||||
*/
|
||||
@interface TYHTTPResponseSerializer : NSObject <TYURLResponseSerialization>
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
/**
|
||||
Creates and returns a serializer with default configuration.
|
||||
*/
|
||||
+ (instancetype)serializer;
|
||||
|
||||
///-----------------------------------------
|
||||
/// @name Configuring Response Serialization
|
||||
///-----------------------------------------
|
||||
|
||||
/**
|
||||
The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation.
|
||||
|
||||
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
*/
|
||||
@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
|
||||
|
||||
/**
|
||||
The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation.
|
||||
*/
|
||||
@property (nonatomic, copy, nullable) NSSet <NSString *> *acceptableContentTypes;
|
||||
|
||||
/**
|
||||
Validates the specified response and data.
|
||||
|
||||
In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
|
||||
|
||||
@param response The response to be validated.
|
||||
@param data The data associated with the response.
|
||||
@param error The error that occurred while attempting to validate the response.
|
||||
|
||||
@return `YES` if the response is valid, otherwise `NO`.
|
||||
*/
|
||||
- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response
|
||||
data:(nullable NSData *)data
|
||||
error:(NSError * _Nullable __autoreleasing *)error;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
/**
|
||||
`TYJSONResponseSerializer` is a subclass of `TYHTTPResponseSerializer` that validates and decodes JSON responses.
|
||||
|
||||
By default, `TYJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
|
||||
|
||||
- `application/json`
|
||||
- `text/json`
|
||||
- `text/javascript`
|
||||
|
||||
In RFC 7159 - Section 8.1, it states that JSON text is required to be encoded in UTF-8, UTF-16, or UTF-32, and the default encoding is UTF-8. NSJSONSerialization provides support for all the encodings listed in the specification, and recommends UTF-8 for efficiency. Using an unsupported encoding will result in serialization error. See the `NSJSONSerialization` documentation for more details.
|
||||
*/
|
||||
@interface TYJSONResponseSerializer : TYHTTPResponseSerializer
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
/**
|
||||
Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
|
||||
*/
|
||||
@property (nonatomic, assign) NSJSONReadingOptions readingOptions;
|
||||
|
||||
/**
|
||||
Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL removesKeysWithNullValues;
|
||||
|
||||
/**
|
||||
Creates and returns a JSON serializer with specified reading and writing options.
|
||||
|
||||
@param readingOptions The specified JSON reading options.
|
||||
*/
|
||||
+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYXMLParserResponseSerializer` is a subclass of `TYHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects.
|
||||
|
||||
By default, `TYXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
|
||||
|
||||
- `application/xml`
|
||||
- `text/xml`
|
||||
*/
|
||||
@interface TYXMLParserResponseSerializer : TYHTTPResponseSerializer
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
|
||||
/**
|
||||
`TYXMLDocumentResponseSerializer` is a subclass of `TYHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
|
||||
|
||||
By default, `TYXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
|
||||
|
||||
- `application/xml`
|
||||
- `text/xml`
|
||||
*/
|
||||
@interface TYXMLDocumentResponseSerializer : TYHTTPResponseSerializer
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
/**
|
||||
Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSXMLDocument` documentation section "Input and Output Options". `0` by default.
|
||||
*/
|
||||
@property (nonatomic, assign) NSUInteger options;
|
||||
|
||||
/**
|
||||
Creates and returns an XML document serializer with the specified options.
|
||||
|
||||
@param mask The XML document options.
|
||||
*/
|
||||
+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYPropertyListResponseSerializer` is a subclass of `TYHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
|
||||
|
||||
By default, `TYPropertyListResponseSerializer` accepts the following MIME types:
|
||||
|
||||
- `application/x-plist`
|
||||
*/
|
||||
@interface TYPropertyListResponseSerializer : TYHTTPResponseSerializer
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
/**
|
||||
The property list format. Possible values are described in "NSPropertyListFormat".
|
||||
*/
|
||||
@property (nonatomic, assign) NSPropertyListFormat format;
|
||||
|
||||
/**
|
||||
The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions."
|
||||
*/
|
||||
@property (nonatomic, assign) NSPropertyListReadOptions readOptions;
|
||||
|
||||
/**
|
||||
Creates and returns a property list serializer with a specified format, read options, and write options.
|
||||
|
||||
@param format The property list format.
|
||||
@param readOptions The property list reading options.
|
||||
*/
|
||||
+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
|
||||
readOptions:(NSPropertyListReadOptions)readOptions;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYImageResponseSerializer` is a subclass of `TYHTTPResponseSerializer` that validates and decodes image responses.
|
||||
|
||||
By default, `TYImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
|
||||
|
||||
- `image/tiff`
|
||||
- `image/jpeg`
|
||||
- `image/gif`
|
||||
- `image/png`
|
||||
- `image/ico`
|
||||
- `image/x-icon`
|
||||
- `image/bmp`
|
||||
- `image/x-bmp`
|
||||
- `image/x-xbitmap`
|
||||
- `image/x-win-bitmap`
|
||||
*/
|
||||
@interface TYImageResponseSerializer : TYHTTPResponseSerializer
|
||||
|
||||
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||
/**
|
||||
The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
|
||||
*/
|
||||
@property (nonatomic, assign) CGFloat imageScale;
|
||||
|
||||
/**
|
||||
Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
`TYCompoundSerializer` is a subclass of `TYHTTPResponseSerializer` that delegates the response serialization to the first `TYHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `TYHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer.
|
||||
*/
|
||||
@interface TYCompoundResponseSerializer : TYHTTPResponseSerializer
|
||||
|
||||
/**
|
||||
The component response serializers.
|
||||
*/
|
||||
@property (readonly, nonatomic, copy) NSArray <id<TYURLResponseSerialization>> *responseSerializers;
|
||||
|
||||
/**
|
||||
Creates and returns a compound serializer comprised of the specified response serializers.
|
||||
|
||||
@warning Each response serializer specified must be a subclass of `TYHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
|
||||
*/
|
||||
+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<TYURLResponseSerialization>> *)responseSerializers;
|
||||
|
||||
@end
|
||||
|
||||
///----------------
|
||||
/// @name Constants
|
||||
///----------------
|
||||
|
||||
/**
|
||||
## Error Domains
|
||||
|
||||
The following error domain is predefined.
|
||||
|
||||
- `NSString * const TYURLResponseSerializationErrorDomain`
|
||||
|
||||
### Constants
|
||||
|
||||
`TYURLResponseSerializationErrorDomain`
|
||||
TYURLResponseSerializer errors. Error codes for `TYURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYURLResponseSerializationErrorDomain;
|
||||
|
||||
/**
|
||||
## User info dictionary keys
|
||||
|
||||
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||
|
||||
- `NSString * const TYNetworkingOperationFailingURLResponseErrorKey`
|
||||
- `NSString * const TYNetworkingOperationFailingURLResponseDataErrorKey`
|
||||
|
||||
### Constants
|
||||
|
||||
`TYNetworkingOperationFailingURLResponseErrorKey`
|
||||
The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `TYURLResponseSerializationErrorDomain`.
|
||||
|
||||
`TYNetworkingOperationFailingURLResponseDataErrorKey`
|
||||
The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `TYURLResponseSerializationErrorDomain`.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingOperationFailingURLResponseErrorKey;
|
||||
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingOperationFailingURLResponseDataErrorKey;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 039291c029c694d38bbd1b5da62f7879
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,516 @@
|
||||
// TYURLSessionManager.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "TYURLResponseSerialization.h"
|
||||
#import "TYURLRequestSerialization.h"
|
||||
#import "TYSecurityPolicy.h"
|
||||
#import "TYCompatibilityMacros.h"
|
||||
#if !TARGET_OS_WATCH
|
||||
#import "TYNetworkReachabilityManager.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
`TYURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
|
||||
|
||||
## Subclassing Notes
|
||||
|
||||
This is the base class for `TYHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `TYURLSessionManager` specifically for HTTP, consider subclassing `TYHTTPSessionManager` instead.
|
||||
|
||||
## NSURLSession & NSURLSessionTask Delegate Methods
|
||||
|
||||
`TYURLSessionManager` implements the following delegate methods:
|
||||
|
||||
### `NSURLSessionDelegate`
|
||||
|
||||
- `URLSession:didBecomeInvalidWithError:`
|
||||
- `URLSession:didReceiveChallenge:completionHandler:`
|
||||
- `URLSessionDidFinishEventsForBackgroundURLSession:`
|
||||
|
||||
### `NSURLSessionTaskDelegate`
|
||||
|
||||
- `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`
|
||||
- `URLSession:task:didReceiveChallenge:completionHandler:`
|
||||
- `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`
|
||||
- `URLSession:task:needNewBodyStream:`
|
||||
- `URLSession:task:didCompleteWithError:`
|
||||
|
||||
### `NSURLSessionDataDelegate`
|
||||
|
||||
- `URLSession:dataTask:didReceiveResponse:completionHandler:`
|
||||
- `URLSession:dataTask:didBecomeDownloadTask:`
|
||||
- `URLSession:dataTask:didReceiveData:`
|
||||
- `URLSession:dataTask:willCacheResponse:completionHandler:`
|
||||
|
||||
### `NSURLSessionDownloadDelegate`
|
||||
|
||||
- `URLSession:downloadTask:didFinishDownloadingToURL:`
|
||||
- `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`
|
||||
- `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`
|
||||
|
||||
If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
|
||||
|
||||
## Network Reachability Monitoring
|
||||
|
||||
Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `TYNetworkReachabilityManager` for more details.
|
||||
|
||||
## NSCoding Caveats
|
||||
|
||||
- Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`.
|
||||
|
||||
## NSCopying Caveats
|
||||
|
||||
- `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original.
|
||||
- Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied.
|
||||
|
||||
@warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
|
||||
*/
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
|
||||
|
||||
/**
|
||||
The managed session.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSURLSession *session;
|
||||
|
||||
/**
|
||||
The operation queue on which delegate callbacks are run.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
|
||||
|
||||
/**
|
||||
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `TYJSONResponseSerializer`.
|
||||
|
||||
@warning `responseSerializer` must not be `nil`.
|
||||
*/
|
||||
@property (nonatomic, strong) id <TYURLResponseSerialization> responseSerializer;
|
||||
|
||||
///-------------------------------
|
||||
/// @name Managing Security Policy
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
The security policy used by created session to evaluate server trust for secure connections. `TYURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
|
||||
*/
|
||||
@property (nonatomic, strong) TYSecurityPolicy *securityPolicy;
|
||||
|
||||
#if !TARGET_OS_WATCH
|
||||
///--------------------------------------
|
||||
/// @name Monitoring Network Reachability
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
The network reachability manager. `TYURLSessionManager` uses the `sharedManager` by default.
|
||||
*/
|
||||
@property (readwrite, nonatomic, strong) TYNetworkReachabilityManager *reachabilityManager;
|
||||
#endif
|
||||
|
||||
///----------------------------
|
||||
/// @name Getting Session Tasks
|
||||
///----------------------------
|
||||
|
||||
/**
|
||||
The data, upload, and download tasks currently run by the managed session.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSArray <NSURLSessionTask *> *tasks;
|
||||
|
||||
/**
|
||||
The data tasks currently run by the managed session.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSArray <NSURLSessionDataTask *> *dataTasks;
|
||||
|
||||
/**
|
||||
The upload tasks currently run by the managed session.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSArray <NSURLSessionUploadTask *> *uploadTasks;
|
||||
|
||||
/**
|
||||
The download tasks currently run by the managed session.
|
||||
*/
|
||||
@property (readonly, nonatomic, strong) NSArray <NSURLSessionDownloadTask *> *downloadTasks;
|
||||
|
||||
///-------------------------------
|
||||
/// @name Managing Callback Queues
|
||||
///-------------------------------
|
||||
|
||||
/**
|
||||
The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used.
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
|
||||
|
||||
/**
|
||||
The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used.
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) dispatch_group_t completionGroup;
|
||||
|
||||
///---------------------
|
||||
/// @name Initialization
|
||||
///---------------------
|
||||
|
||||
/**
|
||||
Creates and returns a manager for a session created with the specified configuration. This is the designated initializer.
|
||||
|
||||
@param configuration The configuration used to create the managed session.
|
||||
|
||||
@return A manager for a newly-created session.
|
||||
*/
|
||||
- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
Invalidates the managed session, optionally canceling pending tasks and optionally resets given session.
|
||||
|
||||
@param cancelPendingTasks Whether or not to cancel pending tasks.
|
||||
@param resetSession Whether or not to reset the session of the manager.
|
||||
*/
|
||||
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession;
|
||||
|
||||
///-------------------------
|
||||
/// @name Running Data Tasks
|
||||
///-------------------------
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionDataTask` with the specified request.
|
||||
|
||||
@param request The HTTP request for the request.
|
||||
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||
*/
|
||||
- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
|
||||
uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||
downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
|
||||
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||
|
||||
///---------------------------
|
||||
/// @name Running Upload Tasks
|
||||
///---------------------------
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionUploadTask` with the specified request for a local file.
|
||||
|
||||
@param request The HTTP request for the request.
|
||||
@param fileURL A URL to the local file to be uploaded.
|
||||
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||
|
||||
@see `attemptsToRecreateUploadTasksForBackgroundSessions`
|
||||
*/
|
||||
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
|
||||
fromFile:(NSURL *)fileURL
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body.
|
||||
|
||||
@param request The HTTP request for the request.
|
||||
@param bodyData A data object containing the HTTP body to be uploaded.
|
||||
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||
*/
|
||||
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
|
||||
fromData:(nullable NSData *)bodyData
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionUploadTask` with the specified streaming request.
|
||||
|
||||
@param request The HTTP request for the request.
|
||||
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||
*/
|
||||
- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||
|
||||
///-----------------------------
|
||||
/// @name Running Download Tasks
|
||||
///-----------------------------
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionDownloadTask` with the specified request.
|
||||
|
||||
@param request The HTTP request for the request.
|
||||
@param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
|
||||
@param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
|
||||
|
||||
@warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method.
|
||||
*/
|
||||
- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
|
||||
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
|
||||
destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
|
||||
completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
|
||||
|
||||
/**
|
||||
Creates an `NSURLSessionDownloadTask` with the specified resume data.
|
||||
|
||||
@param resumeData The data used to resume downloading.
|
||||
@param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
|
||||
@param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
|
||||
*/
|
||||
- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
|
||||
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
|
||||
destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
|
||||
completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
|
||||
|
||||
///---------------------------------
|
||||
/// @name Getting Progress for Tasks
|
||||
///---------------------------------
|
||||
|
||||
/**
|
||||
Returns the upload progress of the specified task.
|
||||
|
||||
@param task The session task. Must not be `nil`.
|
||||
|
||||
@return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable.
|
||||
*/
|
||||
- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task;
|
||||
|
||||
/**
|
||||
Returns the download progress of the specified task.
|
||||
|
||||
@param task The session task. Must not be `nil`.
|
||||
|
||||
@return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable.
|
||||
*/
|
||||
- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task;
|
||||
|
||||
///-----------------------------------------
|
||||
/// @name Setting Session Delegate Callbacks
|
||||
///-----------------------------------------
|
||||
|
||||
/**
|
||||
Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`.
|
||||
|
||||
@param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation.
|
||||
*/
|
||||
- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`.
|
||||
|
||||
@param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge.
|
||||
|
||||
@warning Implementing a session authentication challenge handler yourself totally bypasses TYNetworking's security policy defined in `TYSecurityPolicy`. Make sure you fully understand the implications before implementing a custom session authentication challenge handler. If you do not want to bypass TYNetworking's security policy, use `-setAuthenticationChallengeHandler:` instead.
|
||||
|
||||
@see -securityPolicy
|
||||
@see -setAuthenticationChallengeHandler:
|
||||
*/
|
||||
- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
|
||||
|
||||
///--------------------------------------
|
||||
/// @name Setting Task Delegate Callbacks
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`.
|
||||
|
||||
@param block A block object to be executed when a task requires a new request body stream.
|
||||
*/
|
||||
- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`.
|
||||
|
||||
@param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response.
|
||||
*/
|
||||
- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * _Nullable (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`.
|
||||
|
||||
@param authenticationChallengeHandler A block object to be executed when a session task has received a request specific authentication challenge.
|
||||
|
||||
When implementing an authentication challenge handler, you should check the authentication method first (`challenge.protectionSpace.authenticationMethod `) to decide if you want to handle the authentication challenge yourself or if you want TYNetworking to handle it. If you want TYNetworking to handle the authentication challenge, just return `@(NSURLSessionAuthChallengePerformDefaultHandling)`. For example, you certainly want TYNetworking to handle certificate validation (i.e. authentication method == `NSURLAuthenticationMethodServerTrust`) as defined by the security policy. If you want to handle the challenge yourself, you have four options:
|
||||
|
||||
1. Return `nil` from the authentication challenge handler. You **MUST** call the completion handler with a disposition and credentials yourself. Use this if you need to present a user interface to let the user enter their credentials.
|
||||
2. Return an `NSError` object from the authentication challenge handler. You **MUST NOT** call the completion handler when returning an `NSError `. The returned error will be reported in the completion handler of the task. Use this if you need to abort an authentication challenge with a specific error.
|
||||
3. Return an `NSURLCredential` object from the authentication challenge handler. You **MUST NOT** call the completion handler when returning an `NSURLCredential`. The returned credentials will be used to fulfil the challenge. Use this when you can get credentials without presenting a user interface.
|
||||
4. Return an `NSNumber` object wrapping an `NSURLSessionAuthChallengeDisposition`. Supported values are `@(NSURLSessionAuthChallengePerformDefaultHandling)`, `@(NSURLSessionAuthChallengeCancelAuthenticationChallenge)` and `@(NSURLSessionAuthChallengeRejectProtectionSpace)`. You **MUST NOT** call the completion handler when returning an `NSNumber`.
|
||||
|
||||
If you return anything else from the authentication challenge handler, an exception will be thrown.
|
||||
|
||||
For more information about how URL sessions handle the different types of authentication challenges, see [NSURLSession](https://developer.apple.com/reference/foundation/nsurlsession?language=objc) and [URL Session Programming Guide](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html).
|
||||
|
||||
@see -securityPolicy
|
||||
*/
|
||||
- (void)setAuthenticationChallengeHandler:(id (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition , NSURLCredential * _Nullable)))authenticationChallengeHandler;
|
||||
|
||||
/**
|
||||
Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
|
||||
*/
|
||||
- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`.
|
||||
|
||||
@param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task.
|
||||
*/
|
||||
- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when metrics are finalized related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didFinishCollectingMetrics:`.
|
||||
|
||||
@param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any metrics that were collected in the process of executing the task.
|
||||
*/
|
||||
#if TY_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
- (void)setTaskDidFinishCollectingMetricsBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * _Nullable metrics))block TY_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));
|
||||
#endif
|
||||
///-------------------------------------------
|
||||
/// @name Setting Data Task Delegate Callbacks
|
||||
///-------------------------------------------
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
|
||||
|
||||
@param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response.
|
||||
*/
|
||||
- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`.
|
||||
|
||||
@param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become.
|
||||
*/
|
||||
- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue.
|
||||
*/
|
||||
- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`.
|
||||
|
||||
@param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response.
|
||||
*/
|
||||
- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`.
|
||||
|
||||
@param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session.
|
||||
*/
|
||||
- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block TY_API_UNAVAILABLE(macos);
|
||||
|
||||
///-----------------------------------------------
|
||||
/// @name Setting Download Task Delegate Callbacks
|
||||
///-----------------------------------------------
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`.
|
||||
|
||||
@param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `TYURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error.
|
||||
*/
|
||||
- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue.
|
||||
*/
|
||||
- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`.
|
||||
|
||||
@param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded.
|
||||
*/
|
||||
- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block;
|
||||
|
||||
@end
|
||||
|
||||
///--------------------
|
||||
/// @name Notifications
|
||||
///--------------------
|
||||
|
||||
/**
|
||||
Posted when a task resumes.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidResumeNotification;
|
||||
|
||||
/**
|
||||
Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteNotification;
|
||||
|
||||
/**
|
||||
Posted when a task suspends its execution.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidSuspendNotification;
|
||||
|
||||
/**
|
||||
Posted when a session is invalidated.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYURLSessionDidInvalidateNotification;
|
||||
|
||||
/**
|
||||
Posted when a session download task finished moving the temporary download file to a specified destination successfully.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYURLSessionDownloadTaskDidMoveFileSuccessfullyNotification;
|
||||
|
||||
/**
|
||||
Posted when a session download task encountered an error when moving the temporary download file to a specified destination.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYURLSessionDownloadTaskDidFailToMoveFileNotification;
|
||||
|
||||
/**
|
||||
The raw response data of the task. Included in the userInfo dictionary of the `TYNetworkingTaskDidCompleteNotification` if response data exists for the task.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteResponseDataKey;
|
||||
|
||||
/**
|
||||
The serialized response object of the task. Included in the userInfo dictionary of the `TYNetworkingTaskDidCompleteNotification` if the response was serialized.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteSerializedResponseKey;
|
||||
|
||||
/**
|
||||
The response serializer used to serialize the response. Included in the userInfo dictionary of the `TYNetworkingTaskDidCompleteNotification` if the task has an associated response serializer.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteResponseSerializerKey;
|
||||
|
||||
/**
|
||||
The file path associated with the download task. Included in the userInfo dictionary of the `TYNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteAssetPathKey;
|
||||
|
||||
/**
|
||||
Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `TYNetworkingTaskDidCompleteNotification` if an error exists.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteErrorKey;
|
||||
|
||||
/**
|
||||
The session task metrics taken from the download task. Included in the userInfo dictionary of the `TYNetworkingTaskDidCompleteSessionTaskMetrics`
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const TYNetworkingTaskDidCompleteSessionTaskMetrics;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88c74c801b10346348203e9d227c816b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// TYUUID.h
|
||||
// GMFramework
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/5.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define KTYUDeviceFirstRegist @"ty_sdk_c_device_register"
|
||||
|
||||
@interface TYUUID : NSObject
|
||||
// 获取或创建 md5-UUID
|
||||
+ (NSString *)createOrGetUUID;
|
||||
// 是否越狱
|
||||
+ (BOOL)xy_isJailBreak;
|
||||
// mac地址
|
||||
+ (NSString *)xy_macAddress;
|
||||
// 是否已加载deviceid,如果已经加载,直接返回
|
||||
+ (NSString *)xy_hasDeviceId;
|
||||
// 清除deviceid
|
||||
+ (BOOL)xy_clearDeviceId;
|
||||
// 设备id
|
||||
+ (NSString *)xy_deviceId;
|
||||
// 设备UUID
|
||||
+ (NSString *)xy_uuid;
|
||||
// 设备名字
|
||||
+ (NSString *)deviceName;
|
||||
// 设备Machine
|
||||
+ (NSString *)xy_phoneMachine;
|
||||
// 设备Model
|
||||
+ (NSString *)xy_phoneModel;
|
||||
// 设备启动时间
|
||||
+ (NSString *)bootTimeInSec;
|
||||
// 设备内存容量
|
||||
+ (NSString *)memory;
|
||||
// 设备硬盘容量
|
||||
+ (NSString *)disk;
|
||||
// 系统名字
|
||||
+ (NSString *)xy_osName;
|
||||
// 系统版本
|
||||
+ (NSString *)xy_osVersion;
|
||||
// 系统更新时间
|
||||
+(NSString *)sysFileTime;
|
||||
// 国家
|
||||
+ (NSString *)countryCode;
|
||||
// 语言
|
||||
+ (NSString *)language;
|
||||
// 时区
|
||||
+ (NSString *)timeZone;
|
||||
// 运营商名字
|
||||
+ (NSString *)xy_carrierName;
|
||||
// 运营商代码
|
||||
+ (NSNumber *)xy_carrierNumber;
|
||||
// caid mntid
|
||||
+ (NSString *)mntid;
|
||||
// 设备初始化时间
|
||||
+ (NSString *)fileInitTime;
|
||||
// 传递给CAID的设备名字
|
||||
+ (NSString *)deviceNameForCAID;
|
||||
|
||||
+ (UIViewController *)currentRootViewController;
|
||||
|
||||
+ (UIViewController *)currentTopViewController;
|
||||
|
||||
+ (NSString *)getIDFANotRequest;
|
||||
+ (BOOL)trackingRefuseed;
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b29fa06b2d0e4aa28d71fc5fd259654
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TYUpLoadImage.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/19.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef void(^TYSelectImageBlock)(UIImage *img);
|
||||
@interface TYUpLoadImage : NSObject
|
||||
|
||||
@property(nonatomic, copy) TYSelectImageBlock block;
|
||||
|
||||
- (void)selectImageWithUpLoad:(TYSelectImageBlock)block;
|
||||
- (void)selectImageWithUpLoad;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ca0cec8e0ab04662b5c77374cab2a1e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
// TYUtils.h
|
||||
// UtilsHandle
|
||||
//
|
||||
// Created by hui on 2021/2/20.
|
||||
// Copyright © 2021 周翔宇. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TYUtils : NSObject
|
||||
|
||||
@property (nonatomic, copy, readonly, class) int (^safeInt)(id obj);
|
||||
@property (nonatomic, copy, readonly, class) NSString *(^safeString)(id obj);
|
||||
@property (nonatomic, copy, readonly, class) NSDictionary *(^safeDic)(id obj);
|
||||
@property (nonatomic, strong, readonly, class) NSMutableDictionary *(^safeMutableDic)(id obj);
|
||||
|
||||
|
||||
/// 字典转json
|
||||
/// @param dict 字典
|
||||
+ (NSString *)dicTojsonString:(NSDictionary *)dict;
|
||||
|
||||
|
||||
/// 获取当前时间戳
|
||||
+ (NSString *)getCurrentTimeStamp;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6333224caeb3d427aa44704384231e78
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// UIImage+TYProject.h
|
||||
// TYSDK
|
||||
//
|
||||
// Created by 戴晨惜 on 2017/12/6.
|
||||
// Copyright © 2017年 戴晨惜. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIImage (TYProject)
|
||||
|
||||
/**
|
||||
* 压缩到 20k
|
||||
*/
|
||||
- (UIImage *)CompressionImage;
|
||||
|
||||
/**
|
||||
* 压缩图片大小到 ( bit ) 原比例
|
||||
*/
|
||||
- (UIImage *)CompressionImageToSize:(NSInteger )size;
|
||||
|
||||
// 按大小压缩
|
||||
- (UIImage*)imageWithSize:(CGSize)newSize;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5a44095a8ce1434bb6dae30ccb2e7dd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// XYApiEnumerations.h
|
||||
// XYSDK
|
||||
//
|
||||
// Created by 史良 on 2021/6/4.
|
||||
// Copyright © 2021 刘磊. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef XYApiEnumerations_h
|
||||
#define XYApiEnumerations_h
|
||||
|
||||
typedef NS_ENUM(NSUInteger, XYShareChannelType) {
|
||||
XYShareWeChatChannel = 1,
|
||||
XYShareFaceBookChannel
|
||||
};
|
||||
|
||||
#endif /* XYApiEnumerations_h */
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc06b1980569949508aedd791ae648da
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// XYApiShares.h
|
||||
// XYSDK
|
||||
//
|
||||
// Created by 史良 on 2021/6/4.
|
||||
// Copyright © 2021 刘磊. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef XYApiShares_h
|
||||
#define XYApiShares_h
|
||||
|
||||
#pragma mark - 新版分享
|
||||
#pragma mark - 分享 分享内容模块
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "XYApiEnumerations.h"
|
||||
#import <Photos/PHAsset.h>
|
||||
|
||||
@interface XYShareFBImageConfig : NSMutableDictionary
|
||||
@end
|
||||
@interface XYShareFBVideoConfig : NSMutableDictionary
|
||||
@end
|
||||
@protocol XYShareFBConfigProtocol <NSObject>
|
||||
|
||||
|
||||
/// 创建facebook图片配置
|
||||
/// @param image 图片
|
||||
/// @param userGenerated Specifies whether the photo represented by the receiver was generated by the user or by the application
|
||||
- (XYShareFBImageConfig *)createFBImageWith:(UIImage *)image
|
||||
userGenerated:(BOOL)userGenerated;
|
||||
|
||||
|
||||
/// 创建facebook图片配置
|
||||
/// @param imageURL The URL to the photo; 沙盒URL
|
||||
/// @param userGenerated Specifies whether the photo represented by the receiver was generated by the user or by the application
|
||||
- (XYShareFBImageConfig *)createFBImageWithUrl:(NSURL *)imageURL
|
||||
userGenerated:(BOOL)userGenerated;
|
||||
|
||||
|
||||
/// 创建facebook图片配置 相册中asset
|
||||
/// @param photoAsset The PHAsset that represents the photo in the Photos library.
|
||||
/// @param userGenerated Specifies whether the photo represented by the receiver was generated by the user or by the application
|
||||
- (XYShareFBImageConfig *)createFBImageWithAsset:(PHAsset *)photoAsset
|
||||
userGenerated:(BOOL)userGenerated;
|
||||
|
||||
|
||||
/// 创建Facebook视频配置
|
||||
/// @param data The NSData object that holds the raw video data
|
||||
/// @param previewPhoto The photo that represents the video. 可以不设置预览图传nil即可
|
||||
- (XYShareFBVideoConfig *)createFBVideoWithData:(NSData *)data
|
||||
previewPhoto:(XYShareFBImageConfig *)previewPhoto;
|
||||
|
||||
|
||||
/// 创建Facebook视频配置 参考Fb分享 从相册中选择视频文件后取info中数据
|
||||
/// @param videoAsset The PHAsset that represents the video in the Photos library
|
||||
/// @param previewPhoto The photo that represents the video. 可以不设置预览图传nil即可
|
||||
- (XYShareFBVideoConfig *)createFBVideoWithAsset:(PHAsset *)videoAsset
|
||||
previewPhoto:(XYShareFBImageConfig *)previewPhoto;
|
||||
|
||||
|
||||
/// 创建Facebook视频配置 参考Fb分享 从相册中选择视频文件后取info中数据
|
||||
/// @param VideoURL he URL to the video. Must refer to an asset file.,
|
||||
/// @param previewPhoto The photo that represents the video. 可以不设置预览图传nil即可
|
||||
- (XYShareFBVideoConfig *)createFBVideoWithVideoURL:(NSURL *)VideoURL
|
||||
previewPhoto:(XYShareFBImageConfig *)previewPhoto;
|
||||
|
||||
|
||||
/// fb分享 当有特殊需求时 用来透传特殊参数配置 平时不用调用 以下参数官方参考 https://developers.facebook.com/docs/sharing/ios
|
||||
/// @param quote If specified, the quote text will render with custom styling on top of the link.
|
||||
/// @param hashTagString Hashtag for the content being shared.
|
||||
/// @param peopleIDs List of IDs for taggable people to tag with this content.
|
||||
/// @param placeID The ID for a place to tag with this content
|
||||
/// @param ref A value to be added to the referrer URL when a person follows a link from this shared content on feed.
|
||||
/// @param pageID For shares into Messenger, this pageID will be used to map the app to page and attach attribution to the share.
|
||||
- (void)addFBConfigWithQuote:(NSString *)quote
|
||||
hashTagString:(NSString *)hashTagString
|
||||
peopleIDs:(NSArray<NSString *> *)peopleIDs
|
||||
placeID:(NSString *)placeID
|
||||
ref:(NSString *)ref
|
||||
pageID:(NSString *)pageID;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface XYShareBaseContent : NSObject<XYShareFBConfigProtocol>
|
||||
|
||||
/// 创建分享内容对象
|
||||
/// @param shareChannel 分享渠道
|
||||
+ (instancetype)createShareContentWith:(XYShareChannelType)shareChannel;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/// 文本、连接类分享
|
||||
@interface XYShareMessageContent : XYShareBaseContent
|
||||
|
||||
/// fb链接分享
|
||||
/// @param contentURL This URL will be checked for all link meta tags for linking in platform specific ways. See documentation for App Links (https://developers.facebook.com/docs/applinks/)
|
||||
- (void)configFBContentURLWith:(NSURL *)contentURL;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
用户可以使用分享对话框或自定义界面,通过您的应用将照片分享到 Facebook:
|
||||
|
||||
照片大小必须小于 12MB
|
||||
用户需要安装版本 7.0 或以上的原生 iOS 版 Facebook 应用
|
||||
*/
|
||||
@interface XYShareImageContent : XYShareBaseContent
|
||||
|
||||
|
||||
/// Facebook图片分享 图片配置数组中图片类型需要统一 如:都是UIImage类型、或者都是 本地图片URL类型、 或者都是相册中PHAsset类型
|
||||
/// @param fbImageConfigAry 图片配置列表 可以为单张图片
|
||||
- (void)configFBContentWith:(NSMutableArray<XYShareFBImageConfig *> *)fbImageConfigAry;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
应用用户可通过分享对话框或您专属的自定义界面将视频分享到 Facebook:
|
||||
|
||||
视频大小必须小于 50MB。
|
||||
分享内容的用户应安装版本 26.0 或以上的 iOS 版 Facebook 客户端。
|
||||
*/
|
||||
@interface XYShareVideoContent : XYShareBaseContent
|
||||
|
||||
|
||||
- (void)configFBContentWith:(XYShareFBVideoConfig *)videoConfig;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
应用用户可通过分享对话框从应用向 Facebook 分享同时包含照片和视频的内容。请注意以下事项:
|
||||
|
||||
用户使用的 iOS 版本至少应为 7.0。
|
||||
分享内容的用户应安装版本 52.0 或以上的 iOS 版 Facebook 客户端。
|
||||
照片大小必须小于 12MB,视频大小必须小于 50MB。
|
||||
用户最多可以分享 1 个视频加 29 张照片,或最多分享 30 张照片。
|
||||
*/
|
||||
@interface XYShareMediaContent : XYShareBaseContent
|
||||
|
||||
|
||||
- (void)configFBContentWith:(NSMutableArray<NSMutableDictionary *> *)mediaConfigList;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* XYApiShares_h */
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49d7adba3afe84257ac162eb2ca26e82
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// XYShareContents.h
|
||||
// XYSDK
|
||||
//
|
||||
// Created by 史良 on 2021/6/4.
|
||||
// Copyright © 2021 刘磊. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "XYApiShares.h"
|
||||
#import "XYApiEnumerations.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define kUIImageKey @"UIImageKey"
|
||||
#define kNSURLKey @"NSURLKey"
|
||||
#define kPHImageAssetKey @"PHImageAssetKey"
|
||||
#define kPHVideoAssetKey @"PHVideoAssetKey"
|
||||
#define kNSDataKey @"NSDataKey"
|
||||
#define kXYShareFBImageConfigKey @"XYShareFBImageConfigKey"
|
||||
#define kUserGeneratedKey @"UserGeneratedKey"
|
||||
#define kXYShareFBConfigType @"kXYShareFBConfigType"
|
||||
#define kXYShareFBConfigVideoType @"kXYShareFBConfigVideoType"
|
||||
#define kXYShareFBConfigImageType @"kXYShareFBConfigImageType"
|
||||
|
||||
|
||||
@interface XYShareFBImageConfig ()
|
||||
@end
|
||||
@interface XYShareFBVideoConfig ()
|
||||
@end
|
||||
|
||||
|
||||
@interface XYShareContents : NSObject
|
||||
@end
|
||||
|
||||
/// 新版分享 基类
|
||||
@interface XYShareBaseContent()
|
||||
|
||||
@property (nonatomic, assign) XYShareChannelType shareChannel;
|
||||
@property (nonatomic, strong) NSURL * contentUrl;
|
||||
@property (nonatomic, copy) NSArray * peopleIDs;
|
||||
@property (nonatomic, copy) NSString * quote;
|
||||
@property (nonatomic, copy) NSString * hashTagString;
|
||||
@property (nonatomic, copy) NSString * placeID;
|
||||
@property (nonatomic, copy) NSString * ref;
|
||||
@property (nonatomic, copy) NSString * pageID;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/// 文本消息类
|
||||
@interface XYShareMessageContent ()
|
||||
@end
|
||||
|
||||
|
||||
/// 图片消息类
|
||||
@interface XYShareImageContent ()
|
||||
@property (nonatomic, strong)NSMutableArray<XYShareFBImageConfig *> * fbImageConfigAry;
|
||||
@end
|
||||
|
||||
/// 视频消息类
|
||||
@interface XYShareVideoContent ()
|
||||
@property (nonatomic, strong)XYShareFBVideoConfig * videoConfig;
|
||||
@end
|
||||
|
||||
|
||||
/// 多媒体消息类
|
||||
@interface XYShareMediaContent ()
|
||||
@property (nonatomic, strong)NSMutableArray<NSMutableDictionary *> * mediaConfigAry;
|
||||
@end
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da4cdbe9790ed4d3aa088796370a6d86
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a17aeb799264b48f288bf7ce46ae122f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 401eb3c041aff425fbd0926401c66dcd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
framework module TYSDKCoreKit {
|
||||
umbrella header "TYSDKCoreKit.h"
|
||||
export *
|
||||
|
||||
module * { export * }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9dd68bd682ed343fa9bcef49c9ddfdfb
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
##1.3.4 更新时间 2022-03-12
|
||||
### 更新内容
|
||||
1 新增toast工具
|
||||
2 新增hud工具
|
||||
3 当前包Mac参数没有你猜加密,查看位置:TYDeviceInfoModel.h k_macParamUseNiCai = 1 有你猜
|
||||
|
||||
|
||||
##1.3.3 更新时间 2022-02-09
|
||||
### 更新内容
|
||||
1. mac参数加密开关 该包该参数没有你猜加密
|
||||
|
||||
## 1.3.2 更新时间 2021-09-22
|
||||
### 更新内容
|
||||
1. 新增hud工具
|
||||
|
||||
### 1.3.1 更新时间 2021-06-24
|
||||
### 更新内容
|
||||
1. 新增返程回基类,处理返回数据与公共数据分发
|
||||
|
||||
### 1.3.0 更新时间 2021-06-15
|
||||
### 更新内容
|
||||
* 更新网络工具, 不同工具持有不同http会话
|
||||
* 更新网络工具, 不同工具持有不同http会话地址
|
||||
|
||||
### 1.2.0 更新时间 2021-03-18
|
||||
### 更新内容
|
||||
1.添加外部获取deviceId的方法,添加deviceId的获取监听
|
||||
2.添加网络状态监听,发送网络状态通知
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f525497aec0a4aaf95bdd3895fec74e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 937b6b1aadddd43e2bcb745f312d096d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dce3f60576cc4424998c7cd4387ab7fa
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a72286af8c2049df8b94a604f56770c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user