Last Updated on : 2023-05-22 06:38:29
Message Center UI BizBundle provides the service logic of the message center. The message center keeps the history of push notifications that are classified into alerts, home messages, and notifications. Alerts include device alerts and smart scene history.
On the message center settings page, users can enable or disable one or more push notifications. DND periods can be added for device alerts.
Add the components of the Message Center UI BizBundle to the 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 UI BizBundle.
pod 'TuyaSmartMessageBizBundle'
end
The UI BizBundle relies on the implementation of the protocol TYMessageCenterProtocol
to provide services. You can view the file TYMessageCenterProtocol.h
in the component TYModuleServices
.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol TYMessageCenterProtocol <NSObject>
/// The page of push notifications.
/// @param The animation effect.
- (void)gotoMessageCenterViewControllerWithAnimated:(BOOL)animated;
@end
NS_ASSUME_NONNULL_END
The UI BizBundle depends on the method provided by the protocol TYSmartHomeDataProtocol
to get the current home details required for pairing.
/**
Returns the current home. If the current user does not have a home, `nil` is returned.
@return TuyaSmartHome
*/
- (TuyaSmartHome *)getCurrentHome;
getCurrentHome
method provided by the protocol TYSmartHomeDataProtocol
must be implemented first.ObjC:
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYSmartHomeDataProtocol.h>
- (void)initCurrentHome {
// Registers the protocol to be implemented.
[[TuyaSmartBizCore sharedInstance] registerService:@protocol(TYSmartHomeDataProtocol) withInstance:self];
}
// Implements the protocol method.
- (TuyaSmartHome *)getCurrentHome {
TuyaSmartHome *home = [TuyaSmartHome homeWithHomeId:@"Current home ID"];
return home;
}
Swift:
import TuyaSmartDeviceKit
class TYMessageCenterTest: NSObject,TYSmartHomeDataProtocol{
func test() {
TuyaSmartBizCore.sharedInstance().registerService(TYSmartHomeDataProtocol.self, withInstance: self)
}
func getCurrentHome() -> TuyaSmartHome! {
let home = TuyaSmartHome.init(homeId: 111)
return home
}
}
ObjC:
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYMessageCenterProtocol.h>
- (void)gotoDeviceConfig {
id<TYMessageCenterProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYMessageCenterProtocol)];
[impl gotoMessageCenterViewControllerWithAnimated:YES];
}
Swift:
let impl = TuyaSmartBizCore.sharedInstance().service(of: TYMessageCenterProtocol.self) as? TYMessageCenterProtocol
impl?.gotoMessageCenterViewController(animated: true)
Due to the open capabilities and component dependencies of the UI BizBundle, the message center might not respond when users tap certain types of alerts.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback