Skip to content
galenlin edited this page Jan 25, 2016 · 4 revisions

Web compatible API

  • alert

    alert('message');
  • confirm

    var b = confirm('message')
    alert(b);
  • open page

    <a href="http://www.wequick.net">wequick</a>
  • close page

    window.close();

Native bridge API

Small.invoke(method, parameters, callback);

Internal bridge API

  • alert

    Small.invoke('alert', {
      title: 'title',
      message: 'message', 
      ok: 'OK'
    });
  • confirm

    Small.invoke('confirm', {
      title: 'title',
      message: 'message', 
      buttons: ['OK', 'Cancel']
    }, function(i) {
      alert('Clicked button at index: ' + i);
    });
  • toast

    Small.invoke('toast', {
      message: 'message',
      delay: 1 // unit: second, support 1 or 3, default as 1.
    });
  • hud

    Small.invoke('hud', {
      action: 'show',
      message: 'message'
    });
    
    Small.invoke('hud', {
      action: 'hide',
      delay: 1 // unit: second, support 1 or 3, default as 1.
    });

Custom bridge API

  • Android

    Small.registerJsHandler("some_method", new JsHandler() {
        @Override
        public void handle(Context context, Map<String, Object> parameters, JsResult result) {
            Object ret = doSomeStuff(parameters);
            result.finish(ret);
        }
    });
  • iOS

    [Small registerJSMethod:@"some_method"
                withHandler:^(NSDictionary *parameters, JSValue *callback) {
        id ret = doSomeStuff(parameters);
        [callback callWithArguments:@[ret]];
    }