Skip to content

headers not working in android app #16

@prakashksp20

Description

@prakashksp20

my code with headers is below:
private _url: string;

constructor() {
super();
this.token= JSON.parse(getString("token"));
// Initialize default values.
this._url = 'www.example.com/api/auth';
console.log(this.token);
}

get url(): string {
return this._url;
}

set url(value: string) {
if (this._url !== value) {
this._url = value;
this.notifyPropertyChange('url', value);
}
}

sleep(timeout) {
return new Promise(resolve => setTimeout(resolve, timeout));
}

openLink = async () => {
console.log(this.token);
try {
const { url } = this;
if (await InAppBrowser.isAvailable()) {
const result = await InAppBrowser.open(url, {
// iOS Properties
dismissButtonStyle: 'cancel',
preferredBarTintColor: '#453AA4',
preferredControlTintColor: 'white',
readerMode: false,
animated: true,
modalPresentationStyle: 'overFullScreen',
modalTransitionStyle: 'partialCurl',
modalEnabled: true,
// Android Properties
showTitle: true,
toolbarColor: '#6200EE',
secondaryToolbarColor: 'black',
enableUrlBarHiding: true,
enableDefaultShare: true,
forceCloseOnRedirection: true,
// Specify full animation resource identifier(package:anim/name)
// or only resource name(in case of animation bundled with app).
animations: {
startEnter: 'slide_in_right',
startExit: 'slide_out_left',
endEnter: 'slide_in_left',
endExit: 'slide_out_right'
},
headers: {
'Authorization': this.token
}
});
await this.sleep(800);
alert({
title: 'Response',
message: JSON.stringify(result),
okButtonText: 'Ok'
});
}
else {
openUrl(url);
}
}
catch (error) {
alert({
title: 'Error',
message: error.message,
okButtonText: 'Ok'
});
}
}

output above url is load but unautherized that url error is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions