1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
   | @interface JSAPIExtension : NSObject<GICJSAPIRegisterProtocl> @end @implementation JSAPIExtension +(void)registeJSAPIToJSContext:(JSContext*)context{     context[@"AlertView"] = [JSAlert class]; } @end
  @protocol JSAlert <JSExport> @property NSString* message; @property NSString* title;
  -(instancetype)init; -(void)show;
  JSExportAs(addButton, - (void)addButton:(NSString *)buttonName clicked:(JSValue *)callback); @end
 
 
  @interface JSAlert : NSObject<JSAlert>
  @end
 
  @implementation JSAlert{     UIAlertController *alertVC; }
  @synthesize title;
  -(id)init{     self = [super init];     alertVC = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleAlert];     return self; }
  -(void)setTitle:(NSString *)title{     alertVC.title = title; }
  -(NSString *)title{     return alertVC.title; }
  -(void)setMessage:(NSString *)message{     alertVC.message = message; }
  -(NSString *)message{     return alertVC.message; }
 
  - (void)addButton:(NSString *)buttonName clicked:(JSValue *)callback {     [alertVC addAction:[UIAlertAction actionWithTitle:buttonName style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {         [callback callWithArguments:nil];     }]]; }
  - (void)show {     [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alertVC animated:YES completion:nil]; }
  @end
   |