Last Updated on : 2023-09-19 03:01:05download
The Advanced Functions UI BizBundle provides a container for iOS that hosts the app’s advanced functions. The following advanced functions are available.
Add the components of the Advanced Functions UI BizBundle to Podfile
and run the command pod update
.
source "https://github.com/tuya/tuya-pod-specs"
source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'
target 'your_target_name' do
# Adds the Advanced Functions UI BizBundle.
pod 'ThingPersonalServiceModule'
end
The UI BizBundle relies on the implementation of the protocol ThingPersonalServiceProtocol
to provide services. You can view the ThingPersonalServiceProtocol.h
file in the ThingModuleServices
component.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, ThingPersonalServiceType) {
ThingPersonalServiceTypePushCall, // Phone notification
ThingPersonalServiceTypePushSMS, // Short message service
};
@protocol ThingPersonalServiceProtocol <NSObject>
/**
* Gets the value-added service page.
*
* @param type The type of the value-added service.
* @param callback This block should contain a parameter of UIViewController type and a parameter of NSError type.
*/
- (void)requestPersonalService:(ThingPersonalServiceType)type completionBlock:(void(^)(__kindof UIViewController *page, NSError *error))callback;
@end
None.
UIViewController
. UINavigationController
must be used to call the push
or present
method.UIViewController
)The following advanced function pages are returned:
ThingPersonalServiceTypePushCall
ThingPersonalServiceTypePushSMS
You can integrate with the UI BizBundle and get these pages as needed. New pages will be pushed later, so NavigationController
must encapsulate UIViewController
. Otherwise, navigation to other pages might fail.
#import <ThingSmartBizCore/ThingSmartBizCore.h>
#import <ThingModuleServices/ThingPersonalServiceProtocol.h>
id<ThingPersonalServiceProtocol> psImpl = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingPersonalServiceProtocol)];
[self requestPersonalService:ThingPersonalServiceTypePushSMS completionBlock:^(__kindof UIViewController *page, NSError *error) {
if (error) {
NSLog(@"%@",error);
} else {
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:page];
[self presentViewController:nav animated:YES completion:nil];
}
}];
Swift
let psImpl = ThingSmartBizCore.sharedInstance().service(of: ThingPersonalServiceProtocol.self)
(psImpl as? ThingPersonalServiceProtocol)?.request(.home, completionBlock: { (psVc, error) in
if let e = error {
print("\(e)")
return
}
// push
yourNaviController.pushViewController(psVc!, animated: true)
// present
let naviVc = UINavigationController.init(rootViewController: psVc!)
yourViewController.present(naviVc, animated: true, completion: nil)
})
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback