-
Notifications
You must be signed in to change notification settings - Fork 467
Extend chcp.fetchUpdate method to accept config-url and additional http headers #153
Comments
We need a way to set preferences via native side: e31be1d#commitcomment-17418537 |
…define default download preferences from the native side. #153
Tried it today with the current repo version like function loadUpdate() {
chcp.fetchUpdate(function (error, data) {
if (error) {
console.error('updateService: Failed to load the update', error);
} else {
console.log('updateService: loaded new update', data);
}
}, {Authorization: 'Basic ' + btoa('user:password')});
} Got the error -1. But maybe it's not fully finished or did i do something wrong? |
You are using it wrong. Headers should be putted in function loadUpdate() {
var options = {
'request-headers': {
'Authorization': 'Basic ' + btoa('user:password')
}
};
chcp.fetchUpdate(function (error, data) {
if (error) {
console.error('updateService: Failed to load the update', error);
} else {
console.log('updateService: loaded new update', data);
}
}, options});
} |
And it's only for iOS. Android is not yet implemented. |
Oh sorry, I must have overseen this. Thank you very much, mr King! |
Am I able to include additional headers for automatic updates etc? Is there any more info (docs) on this? |
@wallstudios Right now this functionality is for manual updates only: you can't define custom headers in At the moment there is no additional documentation regarding headers. What more do you want me to add to the first post in this thread? Android version is under construction. |
@nikDemyankov thanks. I'm not sure what other documentation I might need. I'll let you know some feedback once I've implemented and tested. |
forgot to mention yesterday, if I install via cordova plugin add cordova-hot-code-push-plugin the files you added the other day to "/src/ios/Updater/" aren't being installed. But if I install direct from the git they do. cordova plugin add https://github.com/nordnet/cordova-hot-code-push.git |
@nikDemyankov sorry forgot to ask. Any idea how far off the Android version is? Just wanted to reiterate how much I appreciate the work that has gone into this plugin. Great job. |
Yes, because I didn't release it on npmjs.com since it's not finished yet.
I'm hoping to implement it either by the end of this week, or in the beginning of the next one. Should not be too hard, just need to solve some stuff first.
Thanks, that means a lot :) |
…r URLConnection. Adding headers to all requests, if they are set. #153
…ig; added new error code for that. #153
Added code for android. Should work now for both platforms. I hope... |
@nikDemyankov can confirm that it works as expected in both Android and iOS. :) thanks again. |
@wallstudios awesome, thanks for testing! |
Released. |
Is it possible to provide headers from config.xml? |
No, not at the moment. In most cases you need this functionality to provide authorization headers, and hardcoding some keys in |
It sounded pretty cool for me. If I'm right, you can easily update the application with |
Yeah, these are set to |
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:where:
config-file
- url of thechcp.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:
Android:
The text was updated successfully, but these errors were encountered: