index.uts 856 字节
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
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
import { GetProvider, GetProviderOptions, GetProviderSuccess } from '../interface.uts'

const SupportedProviderServiceList = ['oauth', 'share', 'payment', 'push', 'location']

export const getProvider : GetProvider = (options: GetProviderOptions) : void => {
  if (!SupportedProviderServiceList.includes(options.service)) {
    if (options.fail != null) {
      const uniError = new UniError('uni-getProvider', -1, 'Parameter service invalid.');
      options.fail?.(uniError);
    }
  } else {
    const provider = UTSAndroid.getExtApiProviders(options.service)
    // TODO
    // const providers: any[] = []
    if (options.success != null) {
      const result = {
        service: options.service,
        provider,
        errMsg: 'GetProvider:ok'
      } as GetProviderSuccess;
      options.success?.(result);
    }
  }

  options.complete?.({});
}