UIApplication(FWToolkit)
@interface UIApplication (FWToolkit)
注意Info.plist文件URL SCHEME配置项只影响canOpenUrl方法,不影响openUrl。微信返回app就是获取sourceUrl,直接openUrl实现。因为跳转微信的时候,来源app肯定已打开过,可以跳转,只要不检查canOpenUrl,就可以跳转回app
-
读取应用名称
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_appName;
-
读取应用显示名称,未配置时读取名称
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_appDisplayName;
-
读取应用主版本号,示例:1.0.0
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_appVersion;
-
读取应用构建版本号,示例:1.0.0.1
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_appBuildVersion;
-
读取应用唯一标识
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_appIdentifier;
-
读取应用可执行程序名称
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_appExecutable;
-
读取应用信息字典
Declaration
Objective-C
+ (nullable id)fw_appInfo:(nonnull NSString *)key;
-
读取应用启动URL
Declaration
Objective-C
+ (nullable NSURL *)fw_appLaunchURL: (nullable NSDictionary<UIApplicationLaunchOptionsKey, id> *)options;
-
能否打开URL(NSString|NSURL),需配置对应URL SCHEME到Info.plist才能返回YES
Declaration
Objective-C
+ (BOOL)fw_canOpenURL:(nonnull id)url;
-
打开URL,支持NSString|NSURL,即使未配置URL SCHEME,实际也能打开成功,只要调用时已打开过对应App
Declaration
Objective-C
+ (void)fw_openURL:(nonnull id)url;
-
打开URL,支持NSString|NSURL,完成时回调,即使未配置URL SCHEME,实际也能打开成功,只要调用时已打开过对应App
Declaration
Objective-C
+ (void)fw_openURL:(nonnull id)url completionHandler:(nullable void (^)(BOOL))completion;
-
打开通用链接URL,支持NSString|NSURL,完成时回调。如果是iOS10+通用链接且安装了App,打开并回调YES,否则回调NO
Declaration
Objective-C
+ (void)fw_openUniversalLinks:(nonnull id)url completionHandler:(nullable void (^)(BOOL))completion;
-
判断URL是否是系统链接(如AppStore|电话|设置等),支持NSString|NSURL
Declaration
Objective-C
+ (BOOL)fw_isSystemURL:(nonnull id)url;
-
判断URL是否是Scheme链接(非http|https|file链接),支持NSString|NSURL
Declaration
Objective-C
+ (BOOL)fw_isSchemeURL:(nonnull id)url;
-
判断URL是否HTTP链接,支持NSString|NSURL
Declaration
Objective-C
+ (BOOL)fw_isHttpURL:(nonnull id)url;
-
判断URL是否是AppStore链接,支持NSString|NSURL
Declaration
Objective-C
+ (BOOL)fw_isAppStoreURL:(nonnull id)url;
-
打开AppStore下载页
Declaration
Objective-C
+ (void)fw_openAppStore:(nonnull NSString *)appId completionHandler:(nullable void (^)(BOOL))completion;
-
打开AppStore评价页
Declaration
Objective-C
+ (void)fw_openAppStoreReview:(nonnull NSString *)appId completionHandler:(nullable void (^)(BOOL))completion;
-
打开应用内评价,有次数限制
Declaration
Objective-C
+ (void)fw_openAppReview;
-
打开系统应用设置页
Declaration
Objective-C
+ (void)fw_openAppSettings:(nullable void (^)(BOOL))completion;
-
打开系统邮件App
Declaration
Objective-C
+ (void)fw_openMailApp:(nonnull NSString *)email completionHandler:(nullable void (^)(BOOL))completion;
-
打开系统短信App
Declaration
Objective-C
+ (void)fw_openMessageApp:(nonnull NSString *)phone completionHandler:(nullable void (^)(BOOL))completion;
-
打开系统电话App
Declaration
Objective-C
+ (void)fw_openPhoneApp:(nonnull NSString *)phone completionHandler:(nullable void (^)(BOOL))completion;
-
打开系统分享
Declaration
Objective-C
+ (void)fw_openActivityItems:(nonnull NSArray *)activityItems excludedTypes:(nullable NSArray<UIActivityType> *)excludedTypes customBlock:(nullable void (^)( UIActivityViewController *_Nonnull __strong)) customBlock;
-
打开内部浏览器,支持NSString|NSURL
Declaration
Objective-C
+ (void)fw_openSafariController:(nonnull id)url;
-
打开内部浏览器,支持NSString|NSURL,点击完成时回调
Declaration
Objective-C
+ (void)fw_openSafariController:(nonnull id)url completionHandler:(nullable void (^)(void))completion;
-
打开短信控制器,完成时回调
Declaration
Objective-C
+ (void)fw_openMessageController: (nonnull MFMessageComposeViewController *)controller completionHandler:(nullable void (^)(BOOL))completion;
-
打开邮件控制器,完成时回调
Declaration
Objective-C
+ (void)fw_openMailController:(nonnull MFMailComposeViewController *)controller completionHandler:(nullable void (^)(BOOL))completion;
-
打开Store控制器,完成时回调
Declaration
Objective-C
+ (void)fw_openStoreController: (nonnull NSDictionary<NSString *, id> *)parameters completionHandler:(nullable void (^)(BOOL))completion;
-
打开视频播放器,支持AVPlayerItem|NSURL|NSString
Declaration
Objective-C
+ (nullable AVPlayerViewController *)fw_openVideoPlayer:(nonnull id)url;
-
打开音频播放器,支持NSURL|NSString
Declaration
Objective-C
+ (nullable AVAudioPlayer *)fw_openAudioPlayer:(nonnull id)url;
-
播放内置声音文件
Declaration
Objective-C
+ (SystemSoundID)fw_playSystemSound:(nonnull NSString *)file;
-
停止播放内置声音文件
Declaration
Objective-C
+ (void)fw_stopSystemSound:(SystemSoundID)soundId;
-
播放内置震动
Declaration
Objective-C
+ (void)fw_playSystemVibrate;
-
播放触控反馈
Declaration
Objective-C
+ (void)fw_playImpactFeedback:(UIImpactFeedbackStyle)style;
-
语音朗读文字,可指定语言(如zh-CN)
Declaration
Objective-C
+ (void)fw_playSpeechUtterance:(nonnull NSString *)string language:(nullable NSString *)languageCode;
-
是否是盗版(不是从AppStore安装)
Declaration
Objective-C
@property (class, nonatomic, readonly) BOOL fw_isPirated;
-
是否是Testflight版本
Declaration
Objective-C
@property (class, nonatomic, readonly) BOOL fw_isTestflight;