Native Container
It is context unaware native container application. It uses object web view control (webView at Android and UIWebView at iOS) to render the HTML pages. This container has also inbuilt logic to understand the Mobilet protocol via mobilet manager interface (MMI). Mobilet Protocol represents to Smart Event; underlying JS can send Smart Events to corresponding container application to perform specific task.
In case of Android; container uses JavaScriptInterface to receive Smart Events from Web layer. However iOS Smart Container intercepts shouldStartLoadWithRequest delegate of UIWebView to receive SmartEvent.
Design of container is same for iOS and Android. It heavily relays at observer patterns and uses interfaces/delegates for decoupling of components.
Native Container - Android
Container basically comprises of implementation approach named as “Services”. Services are requested from web layer for accessing device/platform specific capabilities like HTTP, Database, Persistent, Camera, File read and Map etc.
Services
All the services support by native container are implemented in same pattern as specified below.
Services Sequence Diagram:
Notifiers
All the notifiers support by native container are implemented in same pattern as specified below.
Notifiers Sequence Diagram:
Description
SmartViewActivity
This class holds object of WebView. It also keeps URI of html page that need to be rendered on UI.
This class implements following listeners:
- To receive SmartEvent this class implements SmartInterfaceListener (JavaScriptInterface) interface. After receiving the SmartEvent, MobiletManager starts the processing of requested event
- To get the completion notification, SmartViewActivity implements SmartConnectorListener interface and uses following methods
- onFinishProcessingWithError
- onFinishProcessingWithOptions
Prerequisite: For any appIt enabled application, native applications Activity should be inherited from SmartViewActivity.
MobiletManager
This class is responsible to check sanity of event using SmartEvent. Also provides valid smart event to SmartEventProcessor for further processing. It implements SmartEventLister to get processing results from SmartEventProcessor. Events could be of type named as CO-EVENT, WEB-EVENT or APP-EVENT. MobiletManager sends notification of WEB-EVENT processing to SmartViewActivity using SmartConnectorListener and send APP-EVENT using SmartAppListener.
SmartEventProcessor
It is responsible for handling of WEB-EVENTs. It uses services of SmartServiceRouter to get allocation of desired service as per the demand of WEB-EVENTs. In case of APP-EVENT it just passes notification back to MobiletManager using SmartEventListener. It implements SmartServiceListener to get processing updates of active SmartService.
SmartServiceRouter
It is based on factory pattern. It maintains the pool of Services, on new requests it checks the availability of request in pool. If it is available then it uses the reference else it creates the object of new services makes entry in pool and then returns the object of service.
SmartService
It is abstract class for services. All individual service classes are derived from SmartService.
SmartEvent
It is a class for capturing details of request and response from web to native layer. Event used at native layer for processing of desired request.
NotifierEventProcessor
It is responsible for processing the NotifierEvent received from the web layer for processing. NotifierEvent provided by the web layer can be either for registering or unregistering to any of the notifier. Once the NotifierEvent is received from the web layer, it is the responsibility of NotifierEventProcessor to determine the type of Notifier that can handle the event and routes the request (for register or unregister) to the concerned Notifier.
NotifierEventRouter
It is based on factory pattern. It maintains the pool of Notifiers and whenever a request for notifier operation is received from the web layer, then returns a new instance of the notifier.
SmartNotifier
It is the parent class of all the notifiers. It exposes common notifier operations like register and unregister notifier which needs to be implemented by the child classes.
NotifierEvent
NotifierEvent is a model that holds the request and response of the Notifier operations. When request is received for registering or unregistering a notifier, then one instance of the NotifierEvent is created that covers the entire registration process. When a system event is triggered for which user has registered the notifier, like Push notification or Network State, then a new instance of the NotifierEvent is created and the response is sent to the web layer
Utility
It is a package of utility classes. This utility classes are used by Services. Utility may have platform specific classes and implementations.
Native Container - iOS
Container basically comprises of implementation approach named as “Services”. Services are requested from web layer for accessing device/platform specific capabilities like HTTP, Database, Persistent, Camera, File read and Map etc.
Services
All the services support by native container are implemented in same pattern as specified below.
Services Sequence Diagram:
Notifiers
All the notifiers support by native container are implemented in same pattern as specified below.
Notifiers Sequence Diagram:
Description
SmartViewController
This class uses object of UIWebView. It also keeps URI of html page that need to be rendered on UI.
This class implements following listeners:
- To get the completion notification, SmartViewController implements SmartConnectorDelegate and uses following methods
- didFinishProcessingWithOptions
- didFinishProcessingWithError
MobiletManager
This class is responsible to check sanity of event using SmartEvent. Also provides valid smart event to SmartEventProcessor for further processing. It implements SmartEventDelegate to get processing results from SmartEventProcessor. Events could be of type named as CO-EVENT, WEB-EVENT or APP-EVENT. MobiletManager sends notification of WEB-EVENT processing to SmartViewController using SmartConnectorDelegate and send APP-EVENT using SmartAppDelegate.
SmartEventProcessor
It is responsible for handling of WEB-EVENTs. It uses services of SmartServiceRouter to get allocation of desired service as per the demand of WEB-EVENTs. In case of APP-EVENT it just passes notification back to MobiletManager using SmartEventDelegate. It implements SmartServiceDelegate to get processing updates of active SmartService.
SmartServiceRouter
It is based on factory pattern. It maintains the pool of Services, on new requests it checks the availability of request in pool. If it is available then it uses the reference else it creates the object of new services makes entry in pool and then returns the object of service.
SmartService
It is abstract class for services. All individual service classes are derived from SmartService.
SmartEvent
It is a class for capturing details of request and response from web to native layer. Event used at native layer for processing of desired request.
NotifierEventProcessor
It is responsible for processing the NotifierEvent received from the web layer for processing. NotifierEvent provided by the web layer can be either for registering or unregistering to any of the notifier. Once the NotifierEvent is received from the web layer, it is the responsibility of NotifierEventProcessor to determine the type of Notifier that can handle the event and routes the request (for register or unregister) to the concerned Notifier.
NotifierEventRouter
It is based on factory pattern. It maintains the pool of Notifiers and whenever a request for notifier operation is received from the web layer, then returns a new instance of the notifier.
SmartNotifier
It is the parent class of all the notifiers. It exposes common notifier operations like register and unregister notifier which needs to be implemented by the child classes.
NotifierEvent
NotifierEvent is a model that holds the request and response of the Notifier operations. When request is received for registering or unregistering a notifier, then one instance of the NotifierEvent is created that covers the entire registration process. When a system event is triggered for which user has registered the notifier, like Push notification or Network State, then a new instance of the NotifierEvent is created and the response is sent to the web layer
Utility
It is a package/namespace of utility classes. This utility classes are used by Services. Utility may have platform specific classes and implementations.