All Products
Search
Document Center

Mobile Platform as a Service:Adaptation and dependency

Last Updated:May 14, 2021

As the shell of AntUI, AntUIShell is mainly used to implement third-party protocols in AntUI. It can be embedded to an mPaaS app and reduce external dependencies of AntUI.

API description

AntUIShellObject.h

  1. //
  2. // AntUIShellObject.h
  3. // AntUIShell
  4. //
  5. #import <Foundation/Foundation.h>
  6. #import <AntUI/AntUI.h>
  7. @interface AntUIShellObject : NSObject<AUThirdPartyAdapter>
  8. @end

Code sample

  1. //
  2. // AntUIShellObject.m
  3. // AntUIShell
  4. //
  5. #import "AntUIShellObject.h"
  6. #import <APMonitor/APMonitor.h>
  7. #import <APMultimedia/APMultimedia.h>
  8. #import <MPBadgeService/MPBadgeService.h>
  9. @implementation AntUIShellObject
  10. #pragma mark ----AUThirdPartyAdapter
  11. /***********************************************************/
  12. // The image protocol APMultimedia.
  13. /*
  14. API adaptation for third-party to download image.
  15. It wraps mulimedia APIs and is implemented by a third party.
  16. */
  17. - (NSString *)thirdPartyGetImage:(NSString *)identifier
  18. business:(NSString *)business
  19. zoom:(CGSize)size
  20. originalSize:(CGSize)originSize
  21. progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
  22. completion:(void (^)(UIImage *image, NSError *error))complete
  23. {
  24. return [[APImageManager manager] getImage:identifier business:business zoom:size originalSize:originSize progress:progress completion:complete];
  25. }
  26. /*
  27. API adaptation for third-party to download UIImageView image.
  28. It is implemented by a third party.
  29. */
  30. - (void)thirdPartypFromImageView:(UIImageView *)fromImgView
  31. setImageWithKey:(NSString *)key
  32. business:(NSString *)business
  33. placeholderImage:(UIImage *)placeholder
  34. zoom:(CGSize)zoom
  35. originalSize:(CGSize)originalSize
  36. progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
  37. completion:(void (^)(UIImage *image, NSError *error))complete
  38. {
  39. if(fromImgView && [fromImgView isKindOfClass:[UIImageView class]]) {
  40. [fromImgView setImageWithKey:key business:business placeholderImage:placeholder zoom:zoom originalSize:originalSize progress:progress completion:complete];
  41. }
  42. }
  43. /***********************************************************/
  44. // The badge protocol MPBadgeService.
  45. /*
  46. Initialize the badge view.
  47. */
  48. - (UIView *) thirdPartyBadgeViewWithFrame:(CGRect)frame
  49. {
  50. return [[MPBadgeView alloc] initWithFrame:frame];
  51. }
  52. /*
  53. Set widgetId for the badge.
  54. */
  55. - (void) thirdPartyBadgeViewWith:(UIView *)badgeView
  56. widgetId:(NSString *) widgetId
  57. {
  58. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  59. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  60. tmpBadgeView.widgetId = widgetId;
  61. }
  62. }
  63. /*
  64. Register the badge view to MPBadgeManager.
  65. */
  66. - (void) thirdPartyBadgeViewReg:(UIView *)badgeView
  67. {
  68. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  69. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  70. [[MPBadgeManager sharedInstance] registerBadgeView:tmpBadgeView];
  71. }
  72. }
  73. /**
  74. * Update the badge style.
  75. * @param badgeView The badge view.
  76. * @param badgeValue: @"." Display a red dot.
  77. * @"new" Display "new".
  78. * @"Number" Display a number. For a number greater than 99, display the more icon (...).
  79. * @"hui" Display "hui".
  80. * @"xin" Display "xin".
  81. * nil Clear the currently displayed content.
  82. *
  83. * @return There is no return value.
  84. */
  85. - (void) thirdPartyBadgeViewWith:(UIView *)badgeView
  86. updateValue:(NSString *)badgeValue
  87. {
  88. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  89. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  90. [tmpBadgeView updateBadgeValue:badgeValue];
  91. }
  92. }
  93. /*
  94. Provide business personnel with an API for monitoring badge control updates.
  95. The type of widgetInfo is MPWidgetInfo.
  96. */
  97. - (void) thirdPartyBadgeViewWith:(UIView *)badgeView
  98. updateBlock:(void(^)(id widgetInfo, BOOL isShow)) updateBlock
  99. {
  100. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  101. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  102. if(updateBlock) {
  103. tmpBadgeView.updateBlock = updateBlock;
  104. }
  105. }
  106. }
  107. /*
  108. The tracking protocol APMonitor.
  109. */
  110. // The tracking protocol of actionName of the button.
  111. - (void) thirdPartySetButtonActionLog:(UIButton *)button
  112. actionNameLog:(NSString *)actionName
  113. {
  114. if(button && [button isKindOfClass:[UIButton class]]) {
  115. button.actionName = actionName;
  116. }
  117. }
  118. /*
  119. The notification protocol AUCardMenu/AUFloatMenu.
  120. */
  121. /*
  122. AUCardMenu registers the logout notification, ensuring that AUCardMenu is destroyed upon logout in a timely manner.
  123. */
  124. - (NSString *) thirdPartyCardMenuDismissNotiName
  125. {
  126. return @"SAAccountDidExitNotification";
  127. }
  128. /*
  129. AUFloatMenu registers alerView kShareTokenAlertViewShownNotification.
  130. */
  131. - (NSString *) thirdPartyFloatMenuDismissFromAlertNotiName
  132. {
  133. return @"kShareTokenAlertViewShownNotification";
  134. }
  135. /*
  136. AUFloatMenu registers alerView SALoginAppWillStartNotification.
  137. */
  138. - (NSString *) thirdPartyFloatMenuDismissFromLoginNotiName
  139. {
  140. return @"SALoginAppWillStartNotification";
  141. }
  142. @end