Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Extend chcp.fetchUpdate method to accept config-url and additional http headers #153

@nikDemyankov

Description

@nikDemyankov

Right now chcp.fecthUpdate method can accept only callback method. It would be nice to be able to pass additional data to it. For example:

var options = {
  'config-file': 'https://mydomain.com/chcp.json',
  'request-headers': {
    'foo': 'bar'
  }
};

chcp.fetchUpdate(function (error, data) {
}, options);

where:

  • config-file - url of the chcp.json config on the server. Right now you need to use chcp.configure() to set it before fetching the update. If implemented - we don't need to do this anymore.
  • request-headers - additional http headers, that we can set from JS side. For example, auth headers.

If you are native developer and want to use an embedded web views - you can define fetch update preferences from the native side. For that you need to obtain the instance of the plugin, that is initialised for your web view - and set default fetch update options property as described below.

iOS:

NSURL *chcpJsonfileURL = [NSURL URLWithString:@"http://somedomain.com/path/chcp.json"];
NSDictionary<NSString *, NSString *> *requestHeaders = @{@"foo": @"bar"};

HCPFetchUpdateOptions *options = [[HCPFetchUpdateOptions alloc] initWithConfigURL:chcpJsonFileURL requestHeaders:requestHeaders];
chcpPluginInstance.defaultFetchUpdateOptions = options;

Android:

final String chcpJsonFileURL = "http://somedomain.com/path/chcp.json";
final Map<String, String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("foo", "bar");
final FetchUpdateOptions options = new FetchUpdateOptions(chcpJsonFileURL, requestHeaders);

chcpPluginInstance.setDefaultFetchUpdateOptions(options);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions