Skip to content

Commit e021b8d

Browse files
committed
fix: ios crash with cache on < 13
1 parent 5795746 commit e021b8d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "Nativescript plugin for gestures",
55
"scripts": {
6-
"tsc": "cp src/index.d.ts plugin && tsc -skipLibCheck -d",
6+
"tsc": "cp src/https.d.ts plugin && tsc -skipLibCheck -d",
77
"clean": "rimraf ./plugin/**/*.d.ts ./plugin/**/*.js ./plugin/**/*.js.map plugin/node_modules plugin/package-lock.json",
88
"build.plugin": " cp README.md plugin/ && rm -f .tsbuildinfo && npm run tsc",
99
"build.android": "bash src-native/android/build.sh",

plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Nativescript plugin for gestures",
55
"main": "https",
66
"sideEffects": false,
7-
"typings": "index.d.ts",
7+
"typings": "https.d.ts",
88
"nativescript": {
99
"platforms": {
1010
"android": "6.2.1",

src/index.d.ts renamed to src/https.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export function enableSSLPinning(options: Https.HttpsSSLPinningOptions);
55
export function disableSSLPinning();
66

77
export function request(options: Https.HttpsRequestOptions): Promise<Https.HttpsResponse>;
8-
export function setCache(options?: Https.CacheOptions)
9-
export function clearCache()
8+
export function setCache(options?: Https.CacheOptions);
9+
export function clearCache();
1010
export function createRequest(opts: Https.HttpsRequestOptions): Https.HttpsRequest;
1111

1212
export * from './https.common';

src/https.ios.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let cache: NSURLCache;
55

66
export function setCache(options?: Https.CacheOptions) {
77
if (options) {
8-
cache = NSURLCache.alloc().initWithMemoryCapacityDiskCapacityDirectoryURL(options.memorySize, options.diskSize, NSURL.URLWithString(options.diskLocation));
8+
cache = NSURLCache.alloc().initWithMemoryCapacityDiskCapacityDiskPath(options.memorySize, options.diskSize, options.diskLocation);
99
} else {
1010
cache = null;
1111
}
@@ -254,7 +254,7 @@ class HttpsResponse implements Https.HttpsResponseLegacy {
254254
return Promise.resolve(this.imageSource);
255255
}
256256
return new Promise<ImageSource>((resolve, reject) => {
257-
(<any>UIImage).tns_decodeImageWithDataCompletion(this.data, (image) => {
257+
(UIImage as any).tns_decodeImageWithDataCompletion(this.data, (image) => {
258258
if (image) {
259259
resolve(new ImageSource(image));
260260
} else {
@@ -387,7 +387,7 @@ function bodyToNative(cont) {
387387
}
388388
export function createRequest(opts: Https.HttpsRequestOptions): Https.HttpsRequest {
389389
const manager = AFHTTPSessionManager.alloc().initWithBaseURL(NSURL.URLWithString(opts.url));
390-
const type = opts.headers && opts.headers['Content-Type'] ? <string>opts.headers['Content-Type'] : 'application/json';
390+
const type = opts.headers && opts.headers['Content-Type'] ? (opts.headers['Content-Type'] as string) : 'application/json';
391391
if (type.startsWith('application/json')) {
392392
manager.requestSerializer = AFJSONRequestSerializer.serializer();
393393
manager.responseSerializer = AFJSONResponseSerializer.serializerWithReadingOptions(NSJSONReadingOptions.AllowFragments);

0 commit comments

Comments
 (0)