init
187
angular.json
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"version": 1,
|
||||||
|
"defaultProject": "app",
|
||||||
|
"newProjectRoot": "projects",
|
||||||
|
"projects": {
|
||||||
|
"app": {
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"projectType": "application",
|
||||||
|
"prefix": "app",
|
||||||
|
"schematics": {},
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "www",
|
||||||
|
"index": "src/index.html",
|
||||||
|
"main": "src/main.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.app.json",
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "src/assets",
|
||||||
|
"output": "assets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"glob": "**/*.svg",
|
||||||
|
"input": "node_modules/ionicons/dist/ionicons/svg",
|
||||||
|
"output": "./svg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
{
|
||||||
|
"input": "src/theme/variables.scss"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": "src/global.scss"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"extractCss": true,
|
||||||
|
"namedChunks": false,
|
||||||
|
"aot": true,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ci": {
|
||||||
|
"progress": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "app:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"browserTarget": "app:build:production"
|
||||||
|
},
|
||||||
|
"ci": {
|
||||||
|
"progress": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "app:build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"main": "src/test.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.spec.json",
|
||||||
|
"karmaConfig": "karma.conf.js",
|
||||||
|
"styles": [],
|
||||||
|
"scripts": [],
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "favicon.ico",
|
||||||
|
"input": "src/",
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "src/assets",
|
||||||
|
"output": "/assets"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"ci": {
|
||||||
|
"progress": false,
|
||||||
|
"watch": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"tsconfig.app.json",
|
||||||
|
"tsconfig.spec.json",
|
||||||
|
"e2e/tsconfig.json"
|
||||||
|
],
|
||||||
|
"exclude": ["**/node_modules/**"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"e2e": {
|
||||||
|
"builder": "@angular-devkit/build-angular:protractor",
|
||||||
|
"options": {
|
||||||
|
"protractorConfig": "e2e/protractor.conf.js",
|
||||||
|
"devServerTarget": "app:serve"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"devServerTarget": "app:serve:production"
|
||||||
|
},
|
||||||
|
"ci": {
|
||||||
|
"devServerTarget": "app:serve:ci"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ionic-cordova-build": {
|
||||||
|
"builder": "@ionic/angular-toolkit:cordova-build",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "app:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"browserTarget": "app:build:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ionic-cordova-serve": {
|
||||||
|
"builder": "@ionic/angular-toolkit:cordova-serve",
|
||||||
|
"options": {
|
||||||
|
"cordovaBuildTarget": "app:ionic-cordova-build",
|
||||||
|
"devServerTarget": "app:serve"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"cordovaBuildTarget": "app:ionic-cordova-build:production",
|
||||||
|
"devServerTarget": "app:serve:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cli": {
|
||||||
|
"defaultCollection": "@ionic/angular-toolkit"
|
||||||
|
},
|
||||||
|
"schematics": {
|
||||||
|
"@ionic/angular-toolkit:component": {
|
||||||
|
"styleext": "scss"
|
||||||
|
},
|
||||||
|
"@ionic/angular-toolkit:page": {
|
||||||
|
"styleext": "scss"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
browserslist
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||||
|
# For additional information regarding the format and rule options, please see:
|
||||||
|
# https://github.com/browserslist/browserslist#queries
|
||||||
|
|
||||||
|
# You can see what browsers were selected by your queries by running:
|
||||||
|
# npx browserslist
|
||||||
|
|
||||||
|
> 0.5%
|
||||||
|
last 2 versions
|
||||||
|
Firefox ESR
|
||||||
|
not dead
|
||||||
|
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
127
config.xml
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<widget id="uk.co.aiber.dev" version="1.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||||
|
<name>Aiber</name>
|
||||||
|
<description />
|
||||||
|
<author email="tony@mimetechnologies.com" href="https://mimetechnologies.com">MIME Technologies Ltd</author>
|
||||||
|
<content original-src="index.html" src="http://localhost:8100" />
|
||||||
|
<access origin="*" />
|
||||||
|
<allow-intent href="http://*/*" />
|
||||||
|
<allow-intent href="https://*/*" />
|
||||||
|
<allow-intent href="tel:*" />
|
||||||
|
<allow-intent href="sms:*" />
|
||||||
|
<allow-intent href="mailto:*" />
|
||||||
|
<allow-intent href="geo:*" />
|
||||||
|
<preference name="ScrollEnabled" value="false" />
|
||||||
|
<preference name="BackupWebStorage" value="none" />
|
||||||
|
<preference name="SplashMaintainAspectRatio" value="true" />
|
||||||
|
<preference name="FadeSplashScreenDuration" value="300" />
|
||||||
|
<preference name="SplashShowOnlyFirstTime" value="false" />
|
||||||
|
<preference name="SplashScreen" value="screen" />
|
||||||
|
<preference name="SplashScreenDelay" value="3000" />
|
||||||
|
<preference name="target-device" value="universal" />
|
||||||
|
<preference name="HideKeyboardFormAccessoryBar" value="false" />
|
||||||
|
<platform name="android">
|
||||||
|
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application android:networkSecurityConfig="@xml/network_security_config" />
|
||||||
|
</edit-config>
|
||||||
|
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
|
||||||
|
<allow-intent href="market:*" />
|
||||||
|
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
|
||||||
|
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
|
||||||
|
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
|
||||||
|
<icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
|
||||||
|
<icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
|
||||||
|
<icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
|
||||||
|
<splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
|
||||||
|
<splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
|
||||||
|
<splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
|
||||||
|
<splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
|
||||||
|
<splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
|
||||||
|
<splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
|
||||||
|
<splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
|
||||||
|
<splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
|
||||||
|
<splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
|
||||||
|
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
|
||||||
|
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
|
||||||
|
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
|
||||||
|
</platform>
|
||||||
|
<platform name="ios">
|
||||||
|
<allow-intent href="itms:*" />
|
||||||
|
<allow-intent href="itms-apps:*" />
|
||||||
|
<edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
|
||||||
|
<string>need location access to find things nearby</string>
|
||||||
|
</edit-config>
|
||||||
|
<feature name="Launcher">
|
||||||
|
<param name="ios-package" value="Launcher" />
|
||||||
|
</feature>
|
||||||
|
<icon height="57" src="resources/ios/icon/icon.png" width="57" />
|
||||||
|
<icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
|
||||||
|
<icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
|
||||||
|
<icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
|
||||||
|
<icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
|
||||||
|
<icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
|
||||||
|
<icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
|
||||||
|
<icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
|
||||||
|
<icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
|
||||||
|
<icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
|
||||||
|
<icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
|
||||||
|
<icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
|
||||||
|
<icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
|
||||||
|
<icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
|
||||||
|
<icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
|
||||||
|
<icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
|
||||||
|
<icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
|
||||||
|
<icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
|
||||||
|
<icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
|
||||||
|
<icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
|
||||||
|
<icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
|
||||||
|
<icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
|
||||||
|
<icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
|
||||||
|
<icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
|
||||||
|
<icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
|
||||||
|
<icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
|
||||||
|
<icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
|
||||||
|
<icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
|
||||||
|
<icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
|
||||||
|
<icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
|
||||||
|
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
|
||||||
|
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
|
||||||
|
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
|
||||||
|
<splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
|
||||||
|
<splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
|
||||||
|
<splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
|
||||||
|
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
|
||||||
|
<splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
|
||||||
|
<splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
|
||||||
|
<splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
|
||||||
|
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
|
||||||
|
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
|
||||||
|
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
|
||||||
|
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
|
||||||
|
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
|
||||||
|
<icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
|
||||||
|
<splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
|
||||||
|
<splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
|
||||||
|
<splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
|
||||||
|
<splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
|
||||||
|
</platform>
|
||||||
|
<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
|
||||||
|
<plugin name="cordova-plugin-statusbar" spec="~2.4.2" />
|
||||||
|
<plugin name="cordova-plugin-device" spec="^2.0.2" />
|
||||||
|
<plugin name="cordova-plugin-splashscreen" spec="~5.0.2" />
|
||||||
|
<plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" />
|
||||||
|
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.2.0" />
|
||||||
|
<plugin name="cordova-plugin-advanced-http" spec="~3.0.1" />
|
||||||
|
<plugin name="cordova-plugin-file" spec="^6.0.2" />
|
||||||
|
<plugin name="cordova-plugin-app-version" spec="~0.1.9" />
|
||||||
|
<plugin name="cordova-plugin-geolocation" spec="~4.0.2">
|
||||||
|
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
|
||||||
|
</plugin>
|
||||||
|
<plugin name="cordova-plugin-network-information" spec="~2.0.2" />
|
||||||
|
<plugin name="cordova-plugin-screen-orientation" spec="~3.0.2" />
|
||||||
|
<plugin name="cordova-plugin-x-toast" spec="~2.7.2" />
|
||||||
|
<plugin name="cordova-sqlite-storage" spec="^5.1.0" />
|
||||||
|
<plugin name="uk.co.workingedge.cordova.plugin.sqliteporter" spec="~1.1.1" />
|
||||||
|
<plugin name="cordova-plugin-app-launcher" spec="~0.4.0" />
|
||||||
|
<allow-navigation href="http://localhost:8100" sessionid="4d7bb030" />
|
||||||
|
</widget>
|
36
e2e/protractor.conf.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// @ts-check
|
||||||
|
// Protractor configuration file, see link for more information
|
||||||
|
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||||
|
|
||||||
|
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type { import("protractor").Config }
|
||||||
|
*/
|
||||||
|
exports.config = {
|
||||||
|
allScriptsTimeout: 11000,
|
||||||
|
specs: [
|
||||||
|
'./src/**/*.e2e-spec.ts'
|
||||||
|
],
|
||||||
|
capabilities: {
|
||||||
|
browserName: 'chrome'
|
||||||
|
},
|
||||||
|
directConnect: true,
|
||||||
|
baseUrl: 'http://localhost:4200/',
|
||||||
|
framework: 'jasmine',
|
||||||
|
jasmineNodeOpts: {
|
||||||
|
showColors: true,
|
||||||
|
defaultTimeoutInterval: 30000,
|
||||||
|
print: function() {}
|
||||||
|
},
|
||||||
|
onPrepare() {
|
||||||
|
require('ts-node').register({
|
||||||
|
project: require('path').join(__dirname, './tsconfig.json')
|
||||||
|
});
|
||||||
|
jasmine.getEnv().addReporter(new SpecReporter({
|
||||||
|
spec: {
|
||||||
|
displayStacktrace: StacktraceOption.PRETTY
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
14
e2e/src/app.e2e-spec.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { AppPage } from './app.po';
|
||||||
|
|
||||||
|
describe('new App', () => {
|
||||||
|
let page: AppPage;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
page = new AppPage();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be blank', () => {
|
||||||
|
page.navigateTo();
|
||||||
|
expect(page.getParagraphText()).toContain('Start with Ionic UI Components');
|
||||||
|
});
|
||||||
|
});
|
11
e2e/src/app.po.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { browser, by, element } from 'protractor';
|
||||||
|
|
||||||
|
export class AppPage {
|
||||||
|
navigateTo() {
|
||||||
|
return browser.get('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
getParagraphText() {
|
||||||
|
return element(by.deepCss('app-root ion-content')).getText();
|
||||||
|
}
|
||||||
|
}
|
13
e2e/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../out-tsc/app",
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"jasminewd2",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
47
ionic-migration.json
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"rulesDirectory": ["@ionic/v4-migration-tslint/rules"],
|
||||||
|
"rules": {
|
||||||
|
"ion-action-sheet-method-create-parameters-renamed": true,
|
||||||
|
"ion-alert-method-create-parameters-renamed": true,
|
||||||
|
"ion-back-button-not-added-by-default": {
|
||||||
|
"options": [true],
|
||||||
|
"severity": "warning"
|
||||||
|
},
|
||||||
|
"ion-button-attributes-renamed": true,
|
||||||
|
"ion-button-is-now-an-element": true,
|
||||||
|
"ion-buttons-attributes-renamed": true,
|
||||||
|
"ion-col-attributes-renamed": true,
|
||||||
|
"ion-datetime-capitalization-changed": true,
|
||||||
|
"ion-fab-attributes-renamed": true,
|
||||||
|
"ion-fab-button-is-now-an-element": true,
|
||||||
|
"ion-fab-fixed-content": true,
|
||||||
|
"ion-icon-attribute-is-active-removed": true,
|
||||||
|
"ion-item-attributes-renamed": true,
|
||||||
|
"ion-item-divider-ion-label-required": true,
|
||||||
|
"ion-item-ion-label-required": true,
|
||||||
|
"ion-item-is-now-an-element": true,
|
||||||
|
"ion-item-option-is-now-an-element": true,
|
||||||
|
"ion-item-option-method-get-sliding-percent-renamed": true,
|
||||||
|
"ion-item-options-attribute-values-renamed": true,
|
||||||
|
"ion-label-attributes-renamed": true,
|
||||||
|
"ion-list-header-ion-label-required": true,
|
||||||
|
"ion-loading-method-create-parameters-renamed": true,
|
||||||
|
"ion-menu-events-renamed": true,
|
||||||
|
"ion-menu-toggle-is-now-an-element": true,
|
||||||
|
"ion-navbar-is-now-ion-toolbar": true,
|
||||||
|
"ion-option-is-now-ion-select-option": true,
|
||||||
|
"ion-overlay-method-create-should-use-await": true,
|
||||||
|
"ion-overlay-method-present-should-use-await": true,
|
||||||
|
"ion-radio-attributes-renamed": true,
|
||||||
|
"ion-radio-group-is-now-an-element": true,
|
||||||
|
"ion-radio-slot-required": true,
|
||||||
|
"ion-range-attributes-renamed": true,
|
||||||
|
"ion-segment-button-ion-label-required": true,
|
||||||
|
"ion-spinner-attribute-values-renamed": true,
|
||||||
|
"ion-tabs-refactored": {
|
||||||
|
"options": [true],
|
||||||
|
"severity": "warning"
|
||||||
|
},
|
||||||
|
"ion-text-is-now-an-element": true
|
||||||
|
}
|
||||||
|
}
|
7
ionic.config.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "aiberTest",
|
||||||
|
"integrations": {
|
||||||
|
"cordova": {}
|
||||||
|
},
|
||||||
|
"type": "angular"
|
||||||
|
}
|
31
karma.conf.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Karma configuration file, see link for more information
|
||||||
|
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
config.set({
|
||||||
|
basePath: '',
|
||||||
|
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||||
|
plugins: [
|
||||||
|
require('karma-jasmine'),
|
||||||
|
require('karma-chrome-launcher'),
|
||||||
|
require('karma-jasmine-html-reporter'),
|
||||||
|
require('karma-coverage-istanbul-reporter'),
|
||||||
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
|
],
|
||||||
|
client: {
|
||||||
|
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||||
|
},
|
||||||
|
coverageIstanbulReporter: {
|
||||||
|
dir: require('path').join(__dirname, '../coverage'),
|
||||||
|
reports: ['html', 'lcovonly', 'text-summary'],
|
||||||
|
fixWebpackSourcePaths: true
|
||||||
|
},
|
||||||
|
reporters: ['progress', 'kjhtml'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: true,
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
singleRun: false
|
||||||
|
});
|
||||||
|
};
|
16495
package-lock.json
generated
Normal file
117
package.json
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
{
|
||||||
|
"name": "aiber",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"author": "Ionic Framework",
|
||||||
|
"homepage": "https://ionicframework.com/",
|
||||||
|
"scripts": {
|
||||||
|
"ng": "ng",
|
||||||
|
"start": "ng serve",
|
||||||
|
"build": "ng build",
|
||||||
|
"test": "ng test",
|
||||||
|
"lint": "ng lint",
|
||||||
|
"e2e": "ng e2e",
|
||||||
|
"emulate": "ionic cordova emulate ios --target='914C6DC7-C042-48FC-A076-4A271DD71093' --consolelogs --livereload"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/common": "~10.0.0",
|
||||||
|
"@angular/core": "~10.0.0",
|
||||||
|
"@angular/forms": "~10.0.0",
|
||||||
|
"@angular/platform-browser": "~10.0.0",
|
||||||
|
"@angular/platform-browser-dynamic": "~10.0.0",
|
||||||
|
"@angular/router": "~10.0.0",
|
||||||
|
"@ionic-native/app-launcher": "^5.28.0",
|
||||||
|
"@ionic-native/app-version": "^5.28.0",
|
||||||
|
"@ionic-native/battery-status": "^5.29.0",
|
||||||
|
"@ionic-native/core": "^5.0.0",
|
||||||
|
"@ionic-native/device": "^5.28.0",
|
||||||
|
"@ionic-native/file": "^5.28.0",
|
||||||
|
"@ionic-native/geolocation": "^5.28.0",
|
||||||
|
"@ionic-native/http": "^5.28.0",
|
||||||
|
"@ionic-native/keyboard": "^5.28.0",
|
||||||
|
"@ionic-native/network": "^5.28.0",
|
||||||
|
"@ionic-native/screen-orientation": "^5.28.0",
|
||||||
|
"@ionic-native/splash-screen": "^5.0.0",
|
||||||
|
"@ionic-native/sqlite": "^5.28.0",
|
||||||
|
"@ionic-native/sqlite-porter": "^5.28.0",
|
||||||
|
"@ionic-native/status-bar": "^5.0.0",
|
||||||
|
"@ionic-native/toast": "^5.28.0",
|
||||||
|
"@ionic/angular": "^5.0.0",
|
||||||
|
"@ionic/storage": "^2.3.1",
|
||||||
|
"basic-trend": "^1.0.6",
|
||||||
|
"cordova": "^10.0.0",
|
||||||
|
"cordova-res": "^0.15.1",
|
||||||
|
"moment": "^2.29.0",
|
||||||
|
"native-run": "^1.2.1",
|
||||||
|
"rxjs": "^6.5.5",
|
||||||
|
"rxjs-compat": "^6.6.3",
|
||||||
|
"tslib": "^2.0.0",
|
||||||
|
"zone.js": "~0.10.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular-devkit/build-angular": "~0.1000.0",
|
||||||
|
"@angular/cli": "~10.0.5",
|
||||||
|
"@angular/compiler": "~10.0.0",
|
||||||
|
"@angular/compiler-cli": "~10.0.0",
|
||||||
|
"@angular/language-service": "~10.0.0",
|
||||||
|
"@ionic/angular-toolkit": "^2.3.0",
|
||||||
|
"@types/jasmine": "~3.5.0",
|
||||||
|
"@types/jasminewd2": "~2.0.3",
|
||||||
|
"@types/node": "^12.11.1",
|
||||||
|
"codelyzer": "^6.0.0",
|
||||||
|
"cordova-ios": "^6.1.1",
|
||||||
|
"cordova-plugin-advanced-http": "^3.0.1",
|
||||||
|
"cordova-plugin-app-launcher": "^0.4.0",
|
||||||
|
"cordova-plugin-app-version": "^0.1.9",
|
||||||
|
"cordova-plugin-battery-status": "^2.0.3",
|
||||||
|
"cordova-plugin-device": "^2.0.2",
|
||||||
|
"cordova-plugin-file": "^6.0.2",
|
||||||
|
"cordova-plugin-geolocation": "^4.0.2",
|
||||||
|
"cordova-plugin-ionic-keyboard": "^2.2.0",
|
||||||
|
"cordova-plugin-ionic-webview": "^4.2.1",
|
||||||
|
"cordova-plugin-network-information": "^2.0.2",
|
||||||
|
"cordova-plugin-screen-orientation": "^3.0.2",
|
||||||
|
"cordova-plugin-splashscreen": "^5.0.2",
|
||||||
|
"cordova-plugin-statusbar": "^2.4.2",
|
||||||
|
"cordova-plugin-whitelist": "^1.3.3",
|
||||||
|
"cordova-plugin-x-toast": "^2.7.2",
|
||||||
|
"cordova-sqlite-storage": "^5.1.0",
|
||||||
|
"jasmine-core": "~3.5.0",
|
||||||
|
"jasmine-spec-reporter": "~5.0.0",
|
||||||
|
"karma": "~5.0.0",
|
||||||
|
"karma-chrome-launcher": "~3.1.0",
|
||||||
|
"karma-coverage-istanbul-reporter": "~3.0.2",
|
||||||
|
"karma-jasmine": "~3.3.0",
|
||||||
|
"karma-jasmine-html-reporter": "^1.5.0",
|
||||||
|
"protractor": "~7.0.0",
|
||||||
|
"ts-node": "~8.3.0",
|
||||||
|
"tslint": "~6.1.0",
|
||||||
|
"typescript": "~3.9.5",
|
||||||
|
"uk.co.workingedge.cordova.plugin.sqliteporter": "^1.1.1"
|
||||||
|
},
|
||||||
|
"description": "An Ionic project",
|
||||||
|
"cordova": {
|
||||||
|
"plugins": {
|
||||||
|
"cordova-plugin-whitelist": {},
|
||||||
|
"cordova-plugin-statusbar": {},
|
||||||
|
"cordova-plugin-device": {},
|
||||||
|
"cordova-plugin-splashscreen": {},
|
||||||
|
"cordova-plugin-ionic-webview": {},
|
||||||
|
"cordova-plugin-ionic-keyboard": {},
|
||||||
|
"cordova-plugin-advanced-http": {},
|
||||||
|
"cordova-plugin-app-version": {},
|
||||||
|
"cordova-plugin-geolocation": {},
|
||||||
|
"cordova-plugin-network-information": {},
|
||||||
|
"cordova-plugin-screen-orientation": {},
|
||||||
|
"cordova-plugin-x-toast": {},
|
||||||
|
"cordova-sqlite-storage": {},
|
||||||
|
"uk.co.workingedge.cordova.plugin.sqliteporter": {},
|
||||||
|
"cordova-plugin-file": {},
|
||||||
|
"cordova-plugin-app-launcher": {},
|
||||||
|
"cordova-plugin-battery-status": {}
|
||||||
|
},
|
||||||
|
"platforms": [
|
||||||
|
"ios"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
5
platforms/ios/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*.mode1v3
|
||||||
|
*.perspectivev3
|
||||||
|
*.pbxuser
|
||||||
|
.DS_Store
|
||||||
|
build/
|
708
platforms/ios/Aiber.xcodeproj/project.pbxproj
Executable file
@ -0,0 +1,708 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 52;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
0207DA581B56EA530066E2B4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0207DA571B56EA530066E2B4 /* Images.xcassets */; };
|
||||||
|
1D3623260D0F684500981E51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* AppDelegate.m */; };
|
||||||
|
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
|
||||||
|
301BF552109A68D80062928A /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF535109A57CC0062928A /* libCordova.a */; settings = {ATTRIBUTES = (Required, ); }; };
|
||||||
|
302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; };
|
||||||
|
302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; };
|
||||||
|
6AFF5BF91D6E424B00AB3073 /* CDVLaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6AFF5BF81D6E424B00AB3073 /* CDVLaunchScreen.storyboard */; };
|
||||||
|
F59FC4FF0B0E4FFF8E3F5AF7 /* CDVStatusBar.m in Sources */ = {isa = PBXBuildFile; fileRef = D906CCA5542843399107F579 /* CDVStatusBar.m */; };
|
||||||
|
B9EFAB9047B547AB951B6510 /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 530E8FBA19FA4F4B8BC3768A /* CDVDevice.m */; };
|
||||||
|
0BB90C02415344898EBD521A /* CDVSplashScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = B62D95D183304C749990046F /* CDVSplashScreen.m */; };
|
||||||
|
1CA17AD1A4A944CD98D64064 /* CDVViewController+SplashScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 9300BA4406614ADBB9D3BB73 /* CDVViewController+SplashScreen.m */; };
|
||||||
|
2073EE6BE66B4BA2992A8CBC /* CDVWKWebViewEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = FB533C5BC9994A8ABD881DED /* CDVWKWebViewEngine.m */; };
|
||||||
|
2E2BE61096A74026B36723E4 /* CDVWKWebViewUIDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CF4D7F1844FE46F0B48E3511 /* CDVWKWebViewUIDelegate.m */; };
|
||||||
|
80C0E2DF4E0C43FDA5389006 /* CDVWKProcessPoolFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 204C82990E254EE9ABA42E80 /* CDVWKProcessPoolFactory.m */; };
|
||||||
|
B7933EBC87724668B9A96A68 /* IONAssetHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C298580825E46F69ACB22C7 /* IONAssetHandler.m */; };
|
||||||
|
293B2C4B44D74FE4A8522413 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3D4A76445DA4DF6935702A6 /* WebKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||||
|
FE0FE0C3523346D5B7DE726F /* CDVIonicKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D75C059EDA144AC8748C9E5 /* CDVIonicKeyboard.m */; };
|
||||||
|
13A271408D474C588A0F4C5A /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 548DDEF818BD47C3A37CCF17 /* CDVFile.m */; };
|
||||||
|
D3CA316902F54AB9BB02B2A8 /* CDVLocalFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = B3C88E025C12436CA5A972CA /* CDVLocalFilesystem.m */; };
|
||||||
|
B4E58D28EEF6465FA94A18F6 /* CDVAssetLibraryFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 011D769452124AF196781B40 /* CDVAssetLibraryFilesystem.m */; };
|
||||||
|
B0F76D74BFFC46C2A69B9FB3 /* CordovaHttpPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = D7E5AABF678A4FD3A8217B46 /* CordovaHttpPlugin.m */; };
|
||||||
|
643D60C9ED614BE0862E45E7 /* BinaryRequestSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 491BCAEA6EBA43B3A510EF74 /* BinaryRequestSerializer.m */; };
|
||||||
|
23B231F0AB7A47F18874A465 /* BinaryResponseSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 792338D915244483919192BA /* BinaryResponseSerializer.m */; };
|
||||||
|
36AAA00791E9481D97E2804A /* TextResponseSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DB28EE4C7214C76B97907BC /* TextResponseSerializer.m */; };
|
||||||
|
EC56D95B566B41198ABEF11E /* TextRequestSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 91CD785D05514ADFA75FACF9 /* TextRequestSerializer.m */; };
|
||||||
|
0C942794E504493DA1E93664 /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B73B3B86B674989BE5D3AFC /* AFHTTPSessionManager.m */; };
|
||||||
|
0FC809AB550F4173ABDA82C8 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA9C6F7F6234045BC4A3D28 /* AFNetworkReachabilityManager.m */; };
|
||||||
|
B8EA80D025EB47639E87A355 /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E6A7B0741B34B67A07CA651 /* AFSecurityPolicy.m */; };
|
||||||
|
BF4793136DA0443CA9A02B5C /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = DB218EA6BF6B4A54BD3A8F32 /* AFURLRequestSerialization.m */; };
|
||||||
|
2B33874C2A624B3B931883DA /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 40581A259CC644BE82A03EC3 /* AFURLResponseSerialization.m */; };
|
||||||
|
0147442927374C3AB673752F /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0299860DEE26409B94F651A7 /* AFURLSessionManager.m */; };
|
||||||
|
69E3E943ED55453782497CFE /* SDNetworkActivityIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C1CA0DE1BB841EA9595736C /* SDNetworkActivityIndicator.m */; };
|
||||||
|
763F1393AFBA42A9999F48ED /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 89A2661E515E47E7AC93F37D /* Security.framework */; };
|
||||||
|
2F40DBBD8A3744C686BC7225 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F42C9743A7CB470EA2167E6D /* SystemConfiguration.framework */; };
|
||||||
|
CF02E82D5AD14A39B983B17F /* AppVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F8BF522B6A40158419D127 /* AppVersion.m */; };
|
||||||
|
3E29F33DF30E46F382336369 /* CDVLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = A52146B827404A3F8A873DBC /* CDVLocation.m */; };
|
||||||
|
1E0DA16837464D80843BDC6B /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FF84317A3C54CCCAE3E035D /* CoreLocation.framework */; };
|
||||||
|
CFB338703B15498E91936B45 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 5918F2FA7E8040249A335F09 /* CDVConnection.m */; };
|
||||||
|
A02307659FC047B9B42BEE2E /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = EED4D95FB5444E71BC1ABFA1 /* CDVReachability.m */; };
|
||||||
|
CEA521DDCDAE4DAA9043C1A2 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53B49ABE6B8C4B21B007E217 /* CoreTelephony.framework */; };
|
||||||
|
0D02002587664864AEED1852 /* CDVOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CC4BE0FA470460088CA36AA /* CDVOrientation.m */; };
|
||||||
|
93DCF97F68834C9A8277A2BC /* Toast+UIView.m in Sources */ = {isa = PBXBuildFile; fileRef = 76D3088A511349398F249CE1 /* Toast+UIView.m */; };
|
||||||
|
741520DDA832424697606FE7 /* Toast.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FBDB5C25B924B1CB2495A5D /* Toast.m */; };
|
||||||
|
78378FD47DBF4D49871C3721 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A08219085B92421FAFE476E9 /* QuartzCore.framework */; };
|
||||||
|
A2B270E563EA47DE9868BCCE /* SQLitePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = AB15A32901DB491287F9F138 /* SQLitePlugin.m */; };
|
||||||
|
D3EF83A06DBA441D96C8EFC8 /* CustomPSPDFThreadSafeMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F09CF1A0612847A6A7DAF325 /* CustomPSPDFThreadSafeMutableDictionary.m */; settings = {COMPILER_FLAGS = "-w"; }; };
|
||||||
|
5E07F9B51F4E4637A756E60B /* sqlite3.c in Resources */ = {isa = PBXBuildFile; fileRef = CE5CFEF0D24948809BB435B1 /* sqlite3.c */; settings = {COMPILER_FLAGS = "-w -DSQLITE_THREADSAFE=1 -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE -DSQLITE_DEFAULT_PAGE_SIZE=4096"; }; };
|
||||||
|
3450BB377F1B477E8AB9D0EA /* Launcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE43E797A604F5E99AFF72D /* Launcher.m */; };
|
||||||
|
7F8250A03AE84FB48A6ADDC1 /* CDVBattery.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A97425F273B405FB8387763 /* CDVBattery.m */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
301BF534109A57CC0062928A /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = D2AAC07E0554694100DB518D;
|
||||||
|
remoteInfo = CordovaLib;
|
||||||
|
};
|
||||||
|
301BF550109A68C00062928A /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = D2AAC07D0554694100DB518D;
|
||||||
|
remoteInfo = CordovaLib;
|
||||||
|
};
|
||||||
|
907D8123214C687600058A10 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = C0C01EB21E3911D50056E6CB;
|
||||||
|
remoteInfo = Cordova;
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
0207DA571B56EA530066E2B4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "Aiber/Images.xcassets"; sourceTree = SOURCE_ROOT; };
|
||||||
|
1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
|
1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
|
1D6058910D05DD3D006BFB54 /* Aiber.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Aiber.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
|
301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
|
||||||
|
301BF56E109A69640062928A /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = SOURCE_ROOT; };
|
||||||
|
302D95EE14D2391D003F00A1 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
|
||||||
|
302D95EF14D2391D003F00A1 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
|
||||||
|
302D95F014D2391D003F00A1 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
|
||||||
|
3047A50F1AB8059700498E2A /* build-debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "build-debug.xcconfig"; path = "cordova/build-debug.xcconfig"; sourceTree = SOURCE_ROOT; };
|
||||||
|
3047A5101AB8059700498E2A /* build-release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "build-release.xcconfig"; path = "cordova/build-release.xcconfig"; sourceTree = SOURCE_ROOT; };
|
||||||
|
3047A5111AB8059700498E2A /* build.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = build.xcconfig; path = cordova/build.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||||
|
32CA4F630368D1EE00C91783 /* Aiber-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Aiber-Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
6AFF5BF81D6E424B00AB3073 /* CDVLaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = CDVLaunchScreen.storyboard; path = "Aiber/CDVLaunchScreen.storyboard"; sourceTree = SOURCE_ROOT; };
|
||||||
|
8D1107310486CEB800E47090 /* Aiber-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Aiber-Info.plist"; path = "Aiber/Aiber-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = SOURCE_ROOT; };
|
||||||
|
EB87FDF31871DA8E0020F90C /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; name = www; path = ../../www; sourceTree = "<group>"; };
|
||||||
|
EB87FDF41871DAF40020F90C /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = ../../config.xml; sourceTree = "<group>"; };
|
||||||
|
ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
|
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = "Aiber/config.xml"; sourceTree = "<group>"; };
|
||||||
|
D906CCA5542843399107F579 /* CDVStatusBar.m */ = {isa = PBXFileReference; name = "CDVStatusBar.m"; path = "cordova-plugin-statusbar/CDVStatusBar.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
2F38DBA88AA6491D979C9795 /* CDVStatusBar.h */ = {isa = PBXFileReference; name = "CDVStatusBar.h"; path = "cordova-plugin-statusbar/CDVStatusBar.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
530E8FBA19FA4F4B8BC3768A /* CDVDevice.m */ = {isa = PBXFileReference; name = "CDVDevice.m"; path = "cordova-plugin-device/CDVDevice.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
462698EE7957428B8D626772 /* CDVDevice.h */ = {isa = PBXFileReference; name = "CDVDevice.h"; path = "cordova-plugin-device/CDVDevice.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
B62D95D183304C749990046F /* CDVSplashScreen.m */ = {isa = PBXFileReference; name = "CDVSplashScreen.m"; path = "cordova-plugin-splashscreen/CDVSplashScreen.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
9300BA4406614ADBB9D3BB73 /* CDVViewController+SplashScreen.m */ = {isa = PBXFileReference; name = "CDVViewController+SplashScreen.m"; path = "cordova-plugin-splashscreen/CDVViewController+SplashScreen.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
1F1E18F7BD834458AF155664 /* CDVSplashScreen.h */ = {isa = PBXFileReference; name = "CDVSplashScreen.h"; path = "cordova-plugin-splashscreen/CDVSplashScreen.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
06A1A689E7BC4314B14B96A3 /* CDVViewController+SplashScreen.h */ = {isa = PBXFileReference; name = "CDVViewController+SplashScreen.h"; path = "cordova-plugin-splashscreen/CDVViewController+SplashScreen.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
FB533C5BC9994A8ABD881DED /* CDVWKWebViewEngine.m */ = {isa = PBXFileReference; name = "CDVWKWebViewEngine.m"; path = "cordova-plugin-ionic-webview/CDVWKWebViewEngine.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
CF4D7F1844FE46F0B48E3511 /* CDVWKWebViewUIDelegate.m */ = {isa = PBXFileReference; name = "CDVWKWebViewUIDelegate.m"; path = "cordova-plugin-ionic-webview/CDVWKWebViewUIDelegate.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
204C82990E254EE9ABA42E80 /* CDVWKProcessPoolFactory.m */ = {isa = PBXFileReference; name = "CDVWKProcessPoolFactory.m"; path = "cordova-plugin-ionic-webview/CDVWKProcessPoolFactory.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
2C298580825E46F69ACB22C7 /* IONAssetHandler.m */ = {isa = PBXFileReference; name = "IONAssetHandler.m"; path = "cordova-plugin-ionic-webview/IONAssetHandler.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
6B9E1E7CAE37421E9D7E6B67 /* CDVWKWebViewEngine.h */ = {isa = PBXFileReference; name = "CDVWKWebViewEngine.h"; path = "cordova-plugin-ionic-webview/CDVWKWebViewEngine.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
EDA8EC65B08449AA9EBEA026 /* CDVWKWebViewUIDelegate.h */ = {isa = PBXFileReference; name = "CDVWKWebViewUIDelegate.h"; path = "cordova-plugin-ionic-webview/CDVWKWebViewUIDelegate.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
F576B282416349E7BC6D93F5 /* CDVWKProcessPoolFactory.h */ = {isa = PBXFileReference; name = "CDVWKProcessPoolFactory.h"; path = "cordova-plugin-ionic-webview/CDVWKProcessPoolFactory.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
9DB8C0F82BE34C0E81505387 /* IONAssetHandler.h */ = {isa = PBXFileReference; name = "IONAssetHandler.h"; path = "cordova-plugin-ionic-webview/IONAssetHandler.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
B3D4A76445DA4DF6935702A6 /* WebKit.framework */ = {isa = PBXFileReference; name = "WebKit.framework"; path = "System/Library/Frameworks/WebKit.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
8D75C059EDA144AC8748C9E5 /* CDVIonicKeyboard.m */ = {isa = PBXFileReference; name = "CDVIonicKeyboard.m"; path = "cordova-plugin-ionic-keyboard/CDVIonicKeyboard.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
EF7D40D47AE04612B03341B4 /* CDVIonicKeyboard.h */ = {isa = PBXFileReference; name = "CDVIonicKeyboard.h"; path = "cordova-plugin-ionic-keyboard/CDVIonicKeyboard.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
548DDEF818BD47C3A37CCF17 /* CDVFile.m */ = {isa = PBXFileReference; name = "CDVFile.m"; path = "cordova-plugin-file/CDVFile.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
B3C88E025C12436CA5A972CA /* CDVLocalFilesystem.m */ = {isa = PBXFileReference; name = "CDVLocalFilesystem.m"; path = "cordova-plugin-file/CDVLocalFilesystem.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
011D769452124AF196781B40 /* CDVAssetLibraryFilesystem.m */ = {isa = PBXFileReference; name = "CDVAssetLibraryFilesystem.m"; path = "cordova-plugin-file/CDVAssetLibraryFilesystem.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
E65A26EBE6924FF8AE5407A8 /* CDVFile.h */ = {isa = PBXFileReference; name = "CDVFile.h"; path = "cordova-plugin-file/CDVFile.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
87AA733D78824C4EA08AFAA6 /* CDVLocalFilesystem.h */ = {isa = PBXFileReference; name = "CDVLocalFilesystem.h"; path = "cordova-plugin-file/CDVLocalFilesystem.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
0DDDFDC8D62D4E5AB1BDBCDD /* CDVAssetLibraryFilesystem.h */ = {isa = PBXFileReference; name = "CDVAssetLibraryFilesystem.h"; path = "cordova-plugin-file/CDVAssetLibraryFilesystem.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
D7E5AABF678A4FD3A8217B46 /* CordovaHttpPlugin.m */ = {isa = PBXFileReference; name = "CordovaHttpPlugin.m"; path = "cordova-plugin-advanced-http/CordovaHttpPlugin.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
491BCAEA6EBA43B3A510EF74 /* BinaryRequestSerializer.m */ = {isa = PBXFileReference; name = "BinaryRequestSerializer.m"; path = "cordova-plugin-advanced-http/BinaryRequestSerializer.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
792338D915244483919192BA /* BinaryResponseSerializer.m */ = {isa = PBXFileReference; name = "BinaryResponseSerializer.m"; path = "cordova-plugin-advanced-http/BinaryResponseSerializer.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
5DB28EE4C7214C76B97907BC /* TextResponseSerializer.m */ = {isa = PBXFileReference; name = "TextResponseSerializer.m"; path = "cordova-plugin-advanced-http/TextResponseSerializer.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
91CD785D05514ADFA75FACF9 /* TextRequestSerializer.m */ = {isa = PBXFileReference; name = "TextRequestSerializer.m"; path = "cordova-plugin-advanced-http/TextRequestSerializer.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
6B73B3B86B674989BE5D3AFC /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; name = "AFHTTPSessionManager.m"; path = "cordova-plugin-advanced-http/AFHTTPSessionManager.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
8EA9C6F7F6234045BC4A3D28 /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; name = "AFNetworkReachabilityManager.m"; path = "cordova-plugin-advanced-http/AFNetworkReachabilityManager.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
9E6A7B0741B34B67A07CA651 /* AFSecurityPolicy.m */ = {isa = PBXFileReference; name = "AFSecurityPolicy.m"; path = "cordova-plugin-advanced-http/AFSecurityPolicy.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
DB218EA6BF6B4A54BD3A8F32 /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; name = "AFURLRequestSerialization.m"; path = "cordova-plugin-advanced-http/AFURLRequestSerialization.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
40581A259CC644BE82A03EC3 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; name = "AFURLResponseSerialization.m"; path = "cordova-plugin-advanced-http/AFURLResponseSerialization.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
0299860DEE26409B94F651A7 /* AFURLSessionManager.m */ = {isa = PBXFileReference; name = "AFURLSessionManager.m"; path = "cordova-plugin-advanced-http/AFURLSessionManager.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
0C1CA0DE1BB841EA9595736C /* SDNetworkActivityIndicator.m */ = {isa = PBXFileReference; name = "SDNetworkActivityIndicator.m"; path = "cordova-plugin-advanced-http/SDNetworkActivityIndicator.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
EDDE31E28D074EC4AB4D40E6 /* CordovaHttpPlugin.h */ = {isa = PBXFileReference; name = "CordovaHttpPlugin.h"; path = "cordova-plugin-advanced-http/CordovaHttpPlugin.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
6213F5CF7BA746A2B7D46EC6 /* BinaryRequestSerializer.h */ = {isa = PBXFileReference; name = "BinaryRequestSerializer.h"; path = "cordova-plugin-advanced-http/BinaryRequestSerializer.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
0EF2BBC7DE9A437A9884DFDC /* BinaryResponseSerializer.h */ = {isa = PBXFileReference; name = "BinaryResponseSerializer.h"; path = "cordova-plugin-advanced-http/BinaryResponseSerializer.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
EAD87F535E914C9FB5009163 /* TextResponseSerializer.h */ = {isa = PBXFileReference; name = "TextResponseSerializer.h"; path = "cordova-plugin-advanced-http/TextResponseSerializer.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
605CB391B4B34C418217E03E /* TextRequestSerializer.h */ = {isa = PBXFileReference; name = "TextRequestSerializer.h"; path = "cordova-plugin-advanced-http/TextRequestSerializer.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
E9397DB2526D47B58C3220E9 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; name = "AFHTTPSessionManager.h"; path = "cordova-plugin-advanced-http/AFHTTPSessionManager.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
913DDE97E9244B60ABA0226C /* AFNetworking.h */ = {isa = PBXFileReference; name = "AFNetworking.h"; path = "cordova-plugin-advanced-http/AFNetworking.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
6A29A166C71A48F39622D665 /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; name = "AFNetworkReachabilityManager.h"; path = "cordova-plugin-advanced-http/AFNetworkReachabilityManager.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
397209E8BFC14C16AB9366EB /* AFSecurityPolicy.h */ = {isa = PBXFileReference; name = "AFSecurityPolicy.h"; path = "cordova-plugin-advanced-http/AFSecurityPolicy.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
F6316C5E3D904FFC80D09D06 /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; name = "AFURLRequestSerialization.h"; path = "cordova-plugin-advanced-http/AFURLRequestSerialization.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
D2B45788A3844948AD9EADFE /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; name = "AFURLResponseSerialization.h"; path = "cordova-plugin-advanced-http/AFURLResponseSerialization.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
8D59489DC2A74D4A952D820E /* AFURLSessionManager.h */ = {isa = PBXFileReference; name = "AFURLSessionManager.h"; path = "cordova-plugin-advanced-http/AFURLSessionManager.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
14F809DC4FA348478A6B9DF0 /* SDNetworkActivityIndicator.h */ = {isa = PBXFileReference; name = "SDNetworkActivityIndicator.h"; path = "cordova-plugin-advanced-http/SDNetworkActivityIndicator.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
89A2661E515E47E7AC93F37D /* Security.framework */ = {isa = PBXFileReference; name = "Security.framework"; path = "System/Library/Frameworks/Security.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
F42C9743A7CB470EA2167E6D /* SystemConfiguration.framework */ = {isa = PBXFileReference; name = "SystemConfiguration.framework"; path = "System/Library/Frameworks/SystemConfiguration.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
62F8BF522B6A40158419D127 /* AppVersion.m */ = {isa = PBXFileReference; name = "AppVersion.m"; path = "cordova-plugin-app-version/AppVersion.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
4E50398E18BD4B4E85309F15 /* AppVersion.h */ = {isa = PBXFileReference; name = "AppVersion.h"; path = "cordova-plugin-app-version/AppVersion.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
A52146B827404A3F8A873DBC /* CDVLocation.m */ = {isa = PBXFileReference; name = "CDVLocation.m"; path = "cordova-plugin-geolocation/CDVLocation.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
0C9D5ECDAD4D4B7A9873C1E9 /* CDVLocation.h */ = {isa = PBXFileReference; name = "CDVLocation.h"; path = "cordova-plugin-geolocation/CDVLocation.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
4FF84317A3C54CCCAE3E035D /* CoreLocation.framework */ = {isa = PBXFileReference; name = "CoreLocation.framework"; path = "System/Library/Frameworks/CoreLocation.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
5918F2FA7E8040249A335F09 /* CDVConnection.m */ = {isa = PBXFileReference; name = "CDVConnection.m"; path = "cordova-plugin-network-information/CDVConnection.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
EED4D95FB5444E71BC1ABFA1 /* CDVReachability.m */ = {isa = PBXFileReference; name = "CDVReachability.m"; path = "cordova-plugin-network-information/CDVReachability.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
3758AFD6A2204D1E88659E03 /* CDVConnection.h */ = {isa = PBXFileReference; name = "CDVConnection.h"; path = "cordova-plugin-network-information/CDVConnection.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
F732DFC8F23B4BEC970D231C /* CDVReachability.h */ = {isa = PBXFileReference; name = "CDVReachability.h"; path = "cordova-plugin-network-information/CDVReachability.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
53B49ABE6B8C4B21B007E217 /* CoreTelephony.framework */ = {isa = PBXFileReference; name = "CoreTelephony.framework"; path = "System/Library/Frameworks/CoreTelephony.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
9CC4BE0FA470460088CA36AA /* CDVOrientation.m */ = {isa = PBXFileReference; name = "CDVOrientation.m"; path = "cordova-plugin-screen-orientation/CDVOrientation.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
368E5C7509A74DB08B85B656 /* CDVOrientation.h */ = {isa = PBXFileReference; name = "CDVOrientation.h"; path = "cordova-plugin-screen-orientation/CDVOrientation.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
76D3088A511349398F249CE1 /* Toast+UIView.m */ = {isa = PBXFileReference; name = "Toast+UIView.m"; path = "cordova-plugin-x-toast/Toast+UIView.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
5FBDB5C25B924B1CB2495A5D /* Toast.m */ = {isa = PBXFileReference; name = "Toast.m"; path = "cordova-plugin-x-toast/Toast.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
5E12EB0FA1924DA0ACC7C0B8 /* Toast+UIView.h */ = {isa = PBXFileReference; name = "Toast+UIView.h"; path = "cordova-plugin-x-toast/Toast+UIView.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
A3C86BF73BC4416D957DFC7B /* Toast.h */ = {isa = PBXFileReference; name = "Toast.h"; path = "cordova-plugin-x-toast/Toast.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
A08219085B92421FAFE476E9 /* QuartzCore.framework */ = {isa = PBXFileReference; name = "QuartzCore.framework"; path = "System/Library/Frameworks/QuartzCore.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
AB15A32901DB491287F9F138 /* SQLitePlugin.m */ = {isa = PBXFileReference; name = "SQLitePlugin.m"; path = "cordova-sqlite-storage/SQLitePlugin.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
F09CF1A0612847A6A7DAF325 /* CustomPSPDFThreadSafeMutableDictionary.m */ = {isa = PBXFileReference; name = "CustomPSPDFThreadSafeMutableDictionary.m"; path = "cordova-sqlite-storage/CustomPSPDFThreadSafeMutableDictionary.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
CE5CFEF0D24948809BB435B1 /* sqlite3.c */ = {isa = PBXFileReference; name = "sqlite3.c"; path = "cordova-sqlite-storage/sqlite3.c"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
99B9723651014A67B714767F /* SQLitePlugin.h */ = {isa = PBXFileReference; name = "SQLitePlugin.h"; path = "cordova-sqlite-storage/SQLitePlugin.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
90BE318F15034F01B38EA917 /* sqlite3.h */ = {isa = PBXFileReference; name = "sqlite3.h"; path = "cordova-sqlite-storage/sqlite3.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
3AE43E797A604F5E99AFF72D /* Launcher.m */ = {isa = PBXFileReference; name = "Launcher.m"; path = "cordova-plugin-app-launcher/Launcher.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
A1744E61D6EE44A9B79F910B /* Launcher.h */ = {isa = PBXFileReference; name = "Launcher.h"; path = "cordova-plugin-app-launcher/Launcher.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
1A97425F273B405FB8387763 /* CDVBattery.m */ = {isa = PBXFileReference; name = "CDVBattery.m"; path = "cordova-plugin-battery-status/CDVBattery.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
1D79EB92E52F47BD8C91383F /* CDVBattery.h */ = {isa = PBXFileReference; name = "CDVBattery.h"; path = "cordova-plugin-battery-status/CDVBattery.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
301BF552109A68D80062928A /* libCordova.a in Frameworks */,
|
||||||
|
293B2C4B44D74FE4A8522413 /* WebKit.framework in Frameworks */,
|
||||||
|
763F1393AFBA42A9999F48ED /* Security.framework in Frameworks */,
|
||||||
|
2F40DBBD8A3744C686BC7225 /* SystemConfiguration.framework in Frameworks */,
|
||||||
|
1E0DA16837464D80843BDC6B /* CoreLocation.framework in Frameworks */,
|
||||||
|
CEA521DDCDAE4DAA9043C1A2 /* CoreTelephony.framework in Frameworks */,
|
||||||
|
78378FD47DBF4D49871C3721 /* QuartzCore.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
302D95EE14D2391D003F00A1 /* MainViewController.h */,
|
||||||
|
302D95EF14D2391D003F00A1 /* MainViewController.m */,
|
||||||
|
302D95F014D2391D003F00A1 /* MainViewController.xib */,
|
||||||
|
1D3623240D0F684500981E51 /* AppDelegate.h */,
|
||||||
|
1D3623250D0F684500981E51 /* AppDelegate.m */,
|
||||||
|
);
|
||||||
|
name = Classes;
|
||||||
|
path = "Aiber/Classes";
|
||||||
|
sourceTree = SOURCE_ROOT;
|
||||||
|
};
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1D6058910D05DD3D006BFB54 /* Aiber.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
EB87FDF41871DAF40020F90C /* config.xml */,
|
||||||
|
EB87FDF31871DA8E0020F90C /* www */,
|
||||||
|
EB87FDF11871DA420020F90C /* Staging */,
|
||||||
|
301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */,
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */,
|
||||||
|
307C750510C5A3420062BCA9 /* Plugins */,
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||||
|
);
|
||||||
|
name = CustomTemplate;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
32CA4F630368D1EE00C91783 /* Aiber-Prefix.pch */,
|
||||||
|
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||||
|
ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */,
|
||||||
|
);
|
||||||
|
name = "Other Sources";
|
||||||
|
path = "Aiber";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
0207DA571B56EA530066E2B4 /* Images.xcassets */,
|
||||||
|
3047A50E1AB8057F00498E2A /* config */,
|
||||||
|
8D1107310486CEB800E47090 /* Aiber-Info.plist */,
|
||||||
|
6AFF5BF81D6E424B00AB3073 /* CDVLaunchScreen.storyboard */,
|
||||||
|
);
|
||||||
|
name = Resources;
|
||||||
|
path = "Aiber/Resources";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
B3D4A76445DA4DF6935702A6 /* WebKit.framework */,
|
||||||
|
89A2661E515E47E7AC93F37D /* Security.framework */,
|
||||||
|
F42C9743A7CB470EA2167E6D /* SystemConfiguration.framework */,
|
||||||
|
4FF84317A3C54CCCAE3E035D /* CoreLocation.framework */,
|
||||||
|
53B49ABE6B8C4B21B007E217 /* CoreTelephony.framework */,
|
||||||
|
A08219085B92421FAFE476E9 /* QuartzCore.framework */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
301BF52E109A57CC0062928A /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
301BF535109A57CC0062928A /* libCordova.a */,
|
||||||
|
907D8124214C687600058A10 /* Cordova.framework */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
3047A50E1AB8057F00498E2A /* config */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3047A50F1AB8059700498E2A /* build-debug.xcconfig */,
|
||||||
|
3047A5101AB8059700498E2A /* build-release.xcconfig */,
|
||||||
|
3047A5111AB8059700498E2A /* build.xcconfig */,
|
||||||
|
);
|
||||||
|
name = config;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
307C750510C5A3420062BCA9 /* Plugins */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
D906CCA5542843399107F579 /* CDVStatusBar.m */,
|
||||||
|
2F38DBA88AA6491D979C9795 /* CDVStatusBar.h */,
|
||||||
|
530E8FBA19FA4F4B8BC3768A /* CDVDevice.m */,
|
||||||
|
462698EE7957428B8D626772 /* CDVDevice.h */,
|
||||||
|
B62D95D183304C749990046F /* CDVSplashScreen.m */,
|
||||||
|
9300BA4406614ADBB9D3BB73 /* CDVViewController+SplashScreen.m */,
|
||||||
|
1F1E18F7BD834458AF155664 /* CDVSplashScreen.h */,
|
||||||
|
06A1A689E7BC4314B14B96A3 /* CDVViewController+SplashScreen.h */,
|
||||||
|
FB533C5BC9994A8ABD881DED /* CDVWKWebViewEngine.m */,
|
||||||
|
CF4D7F1844FE46F0B48E3511 /* CDVWKWebViewUIDelegate.m */,
|
||||||
|
204C82990E254EE9ABA42E80 /* CDVWKProcessPoolFactory.m */,
|
||||||
|
2C298580825E46F69ACB22C7 /* IONAssetHandler.m */,
|
||||||
|
6B9E1E7CAE37421E9D7E6B67 /* CDVWKWebViewEngine.h */,
|
||||||
|
EDA8EC65B08449AA9EBEA026 /* CDVWKWebViewUIDelegate.h */,
|
||||||
|
F576B282416349E7BC6D93F5 /* CDVWKProcessPoolFactory.h */,
|
||||||
|
9DB8C0F82BE34C0E81505387 /* IONAssetHandler.h */,
|
||||||
|
8D75C059EDA144AC8748C9E5 /* CDVIonicKeyboard.m */,
|
||||||
|
EF7D40D47AE04612B03341B4 /* CDVIonicKeyboard.h */,
|
||||||
|
548DDEF818BD47C3A37CCF17 /* CDVFile.m */,
|
||||||
|
B3C88E025C12436CA5A972CA /* CDVLocalFilesystem.m */,
|
||||||
|
011D769452124AF196781B40 /* CDVAssetLibraryFilesystem.m */,
|
||||||
|
E65A26EBE6924FF8AE5407A8 /* CDVFile.h */,
|
||||||
|
87AA733D78824C4EA08AFAA6 /* CDVLocalFilesystem.h */,
|
||||||
|
0DDDFDC8D62D4E5AB1BDBCDD /* CDVAssetLibraryFilesystem.h */,
|
||||||
|
D7E5AABF678A4FD3A8217B46 /* CordovaHttpPlugin.m */,
|
||||||
|
491BCAEA6EBA43B3A510EF74 /* BinaryRequestSerializer.m */,
|
||||||
|
792338D915244483919192BA /* BinaryResponseSerializer.m */,
|
||||||
|
5DB28EE4C7214C76B97907BC /* TextResponseSerializer.m */,
|
||||||
|
91CD785D05514ADFA75FACF9 /* TextRequestSerializer.m */,
|
||||||
|
6B73B3B86B674989BE5D3AFC /* AFHTTPSessionManager.m */,
|
||||||
|
8EA9C6F7F6234045BC4A3D28 /* AFNetworkReachabilityManager.m */,
|
||||||
|
9E6A7B0741B34B67A07CA651 /* AFSecurityPolicy.m */,
|
||||||
|
DB218EA6BF6B4A54BD3A8F32 /* AFURLRequestSerialization.m */,
|
||||||
|
40581A259CC644BE82A03EC3 /* AFURLResponseSerialization.m */,
|
||||||
|
0299860DEE26409B94F651A7 /* AFURLSessionManager.m */,
|
||||||
|
0C1CA0DE1BB841EA9595736C /* SDNetworkActivityIndicator.m */,
|
||||||
|
EDDE31E28D074EC4AB4D40E6 /* CordovaHttpPlugin.h */,
|
||||||
|
6213F5CF7BA746A2B7D46EC6 /* BinaryRequestSerializer.h */,
|
||||||
|
0EF2BBC7DE9A437A9884DFDC /* BinaryResponseSerializer.h */,
|
||||||
|
EAD87F535E914C9FB5009163 /* TextResponseSerializer.h */,
|
||||||
|
605CB391B4B34C418217E03E /* TextRequestSerializer.h */,
|
||||||
|
E9397DB2526D47B58C3220E9 /* AFHTTPSessionManager.h */,
|
||||||
|
913DDE97E9244B60ABA0226C /* AFNetworking.h */,
|
||||||
|
6A29A166C71A48F39622D665 /* AFNetworkReachabilityManager.h */,
|
||||||
|
397209E8BFC14C16AB9366EB /* AFSecurityPolicy.h */,
|
||||||
|
F6316C5E3D904FFC80D09D06 /* AFURLRequestSerialization.h */,
|
||||||
|
D2B45788A3844948AD9EADFE /* AFURLResponseSerialization.h */,
|
||||||
|
8D59489DC2A74D4A952D820E /* AFURLSessionManager.h */,
|
||||||
|
14F809DC4FA348478A6B9DF0 /* SDNetworkActivityIndicator.h */,
|
||||||
|
62F8BF522B6A40158419D127 /* AppVersion.m */,
|
||||||
|
4E50398E18BD4B4E85309F15 /* AppVersion.h */,
|
||||||
|
A52146B827404A3F8A873DBC /* CDVLocation.m */,
|
||||||
|
0C9D5ECDAD4D4B7A9873C1E9 /* CDVLocation.h */,
|
||||||
|
5918F2FA7E8040249A335F09 /* CDVConnection.m */,
|
||||||
|
EED4D95FB5444E71BC1ABFA1 /* CDVReachability.m */,
|
||||||
|
3758AFD6A2204D1E88659E03 /* CDVConnection.h */,
|
||||||
|
F732DFC8F23B4BEC970D231C /* CDVReachability.h */,
|
||||||
|
9CC4BE0FA470460088CA36AA /* CDVOrientation.m */,
|
||||||
|
368E5C7509A74DB08B85B656 /* CDVOrientation.h */,
|
||||||
|
76D3088A511349398F249CE1 /* Toast+UIView.m */,
|
||||||
|
5FBDB5C25B924B1CB2495A5D /* Toast.m */,
|
||||||
|
5E12EB0FA1924DA0ACC7C0B8 /* Toast+UIView.h */,
|
||||||
|
A3C86BF73BC4416D957DFC7B /* Toast.h */,
|
||||||
|
AB15A32901DB491287F9F138 /* SQLitePlugin.m */,
|
||||||
|
F09CF1A0612847A6A7DAF325 /* CustomPSPDFThreadSafeMutableDictionary.m */,
|
||||||
|
CE5CFEF0D24948809BB435B1 /* sqlite3.c */,
|
||||||
|
99B9723651014A67B714767F /* SQLitePlugin.h */,
|
||||||
|
90BE318F15034F01B38EA917 /* sqlite3.h */,
|
||||||
|
3AE43E797A604F5E99AFF72D /* Launcher.m */,
|
||||||
|
A1744E61D6EE44A9B79F910B /* Launcher.h */,
|
||||||
|
1A97425F273B405FB8387763 /* CDVBattery.m */,
|
||||||
|
1D79EB92E52F47BD8C91383F /* CDVBattery.h */,
|
||||||
|
);
|
||||||
|
name = Plugins;
|
||||||
|
path = "Aiber/Plugins";
|
||||||
|
sourceTree = SOURCE_ROOT;
|
||||||
|
};
|
||||||
|
EB87FDF11871DA420020F90C /* Staging */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
F840E1F0165FE0F500CFE078 /* config.xml */,
|
||||||
|
301BF56E109A69640062928A /* www */,
|
||||||
|
);
|
||||||
|
name = Staging;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
1D6058900D05DD3D006BFB54 /* Aiber */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Aiber" */;
|
||||||
|
buildPhases = (
|
||||||
|
304B58A110DAC018002A0835 /* Copy www directory */,
|
||||||
|
1D60588D0D05DD3D006BFB54 /* Resources */,
|
||||||
|
1D60588E0D05DD3D006BFB54 /* Sources */,
|
||||||
|
1D60588F0D05DD3D006BFB54 /* Frameworks */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
301BF551109A68C00062928A /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = "Aiber";
|
||||||
|
productName = "Aiber";
|
||||||
|
productReference = 1D6058910D05DD3D006BFB54 /* Aiber.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 1130;
|
||||||
|
TargetAttributes = {
|
||||||
|
1D6058900D05DD3D006BFB54 = {
|
||||||
|
ProvisioningStyle = Automatic;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Aiber" */;
|
||||||
|
compatibilityVersion = "Xcode 11.0";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 1;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectReferences = (
|
||||||
|
{
|
||||||
|
ProductGroup = 301BF52E109A57CC0062928A /* Products */;
|
||||||
|
ProjectRef = 301BF52D109A57CC0062928A /* CordovaLib/CordovaLib.xcodeproj */;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
1D6058900D05DD3D006BFB54 /* Aiber */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXReferenceProxy section */
|
||||||
|
301BF535109A57CC0062928A /* libCordova.a */ = {
|
||||||
|
isa = PBXReferenceProxy;
|
||||||
|
fileType = archive.ar;
|
||||||
|
path = libCordova.a;
|
||||||
|
remoteRef = 301BF534109A57CC0062928A /* PBXContainerItemProxy */;
|
||||||
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
|
};
|
||||||
|
907D8124214C687600058A10 /* Cordova.framework */ = {
|
||||||
|
isa = PBXReferenceProxy;
|
||||||
|
fileType = wrapper.framework;
|
||||||
|
path = Cordova.framework;
|
||||||
|
remoteRef = 907D8123214C687600058A10 /* PBXContainerItemProxy */;
|
||||||
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
|
};
|
||||||
|
/* End PBXReferenceProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
1D60588D0D05DD3D006BFB54 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */,
|
||||||
|
0207DA581B56EA530066E2B4 /* Images.xcassets in Resources */,
|
||||||
|
6AFF5BF91D6E424B00AB3073 /* CDVLaunchScreen.storyboard in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
304B58A110DAC018002A0835 /* Copy www directory */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Copy www directory";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"$SRCROOT/Aiber/Scripts/copy-www-build-step.sh\"";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
1D60588E0D05DD3D006BFB54 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
|
||||||
|
1D3623260D0F684500981E51 /* AppDelegate.m in Sources */,
|
||||||
|
302D95F114D2391D003F00A1 /* MainViewController.m in Sources */,
|
||||||
|
F59FC4FF0B0E4FFF8E3F5AF7 /* CDVStatusBar.m in Sources */,
|
||||||
|
B9EFAB9047B547AB951B6510 /* CDVDevice.m in Sources */,
|
||||||
|
0BB90C02415344898EBD521A /* CDVSplashScreen.m in Sources */,
|
||||||
|
1CA17AD1A4A944CD98D64064 /* CDVViewController+SplashScreen.m in Sources */,
|
||||||
|
2073EE6BE66B4BA2992A8CBC /* CDVWKWebViewEngine.m in Sources */,
|
||||||
|
2E2BE61096A74026B36723E4 /* CDVWKWebViewUIDelegate.m in Sources */,
|
||||||
|
80C0E2DF4E0C43FDA5389006 /* CDVWKProcessPoolFactory.m in Sources */,
|
||||||
|
B7933EBC87724668B9A96A68 /* IONAssetHandler.m in Sources */,
|
||||||
|
FE0FE0C3523346D5B7DE726F /* CDVIonicKeyboard.m in Sources */,
|
||||||
|
13A271408D474C588A0F4C5A /* CDVFile.m in Sources */,
|
||||||
|
D3CA316902F54AB9BB02B2A8 /* CDVLocalFilesystem.m in Sources */,
|
||||||
|
B4E58D28EEF6465FA94A18F6 /* CDVAssetLibraryFilesystem.m in Sources */,
|
||||||
|
B0F76D74BFFC46C2A69B9FB3 /* CordovaHttpPlugin.m in Sources */,
|
||||||
|
643D60C9ED614BE0862E45E7 /* BinaryRequestSerializer.m in Sources */,
|
||||||
|
23B231F0AB7A47F18874A465 /* BinaryResponseSerializer.m in Sources */,
|
||||||
|
36AAA00791E9481D97E2804A /* TextResponseSerializer.m in Sources */,
|
||||||
|
EC56D95B566B41198ABEF11E /* TextRequestSerializer.m in Sources */,
|
||||||
|
0C942794E504493DA1E93664 /* AFHTTPSessionManager.m in Sources */,
|
||||||
|
0FC809AB550F4173ABDA82C8 /* AFNetworkReachabilityManager.m in Sources */,
|
||||||
|
B8EA80D025EB47639E87A355 /* AFSecurityPolicy.m in Sources */,
|
||||||
|
BF4793136DA0443CA9A02B5C /* AFURLRequestSerialization.m in Sources */,
|
||||||
|
2B33874C2A624B3B931883DA /* AFURLResponseSerialization.m in Sources */,
|
||||||
|
0147442927374C3AB673752F /* AFURLSessionManager.m in Sources */,
|
||||||
|
69E3E943ED55453782497CFE /* SDNetworkActivityIndicator.m in Sources */,
|
||||||
|
CF02E82D5AD14A39B983B17F /* AppVersion.m in Sources */,
|
||||||
|
3E29F33DF30E46F382336369 /* CDVLocation.m in Sources */,
|
||||||
|
CFB338703B15498E91936B45 /* CDVConnection.m in Sources */,
|
||||||
|
A02307659FC047B9B42BEE2E /* CDVReachability.m in Sources */,
|
||||||
|
0D02002587664864AEED1852 /* CDVOrientation.m in Sources */,
|
||||||
|
93DCF97F68834C9A8277A2BC /* Toast+UIView.m in Sources */,
|
||||||
|
741520DDA832424697606FE7 /* Toast.m in Sources */,
|
||||||
|
A2B270E563EA47DE9868BCCE /* SQLitePlugin.m in Sources */,
|
||||||
|
D3EF83A06DBA441D96C8EFC8 /* CustomPSPDFThreadSafeMutableDictionary.m in Sources */,
|
||||||
|
5E07F9B51F4E4637A756E60B /* sqlite3.c in Resources */,
|
||||||
|
3450BB377F1B477E8AB9D0EA /* Launcher.m in Sources */,
|
||||||
|
7F8250A03AE84FB48A6ADDC1 /* CDVBattery.m in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
301BF551109A68C00062928A /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
name = CordovaLib;
|
||||||
|
targetProxy = 301BF550109A68C00062928A /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
1D6058940D05DD3E006BFB54 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 3047A50F1AB8059700498E2A /* build-debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
GCC_PREFIX_HEADER = "Aiber/Aiber-Prefix.pch";
|
||||||
|
GCC_THUMB_SUPPORT = NO;
|
||||||
|
GCC_VERSION = "";
|
||||||
|
INFOPLIST_FILE = "Aiber/Aiber-Info.plist";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = uk.co.aiber.dev;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
1D6058950D05DD3E006BFB54 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 3047A5101AB8059700498E2A /* build-release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
COPY_PHASE_STRIP = YES;
|
||||||
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
GCC_PREFIX_HEADER = "Aiber/Aiber-Prefix.pch";
|
||||||
|
GCC_THUMB_SUPPORT = NO;
|
||||||
|
GCC_VERSION = "";
|
||||||
|
INFOPLIST_FILE = "Aiber/Aiber-Info.plist";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = uk.co.aiber.dev;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C01FCF4F08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 3047A5111AB8059700498E2A /* build.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = c99;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_THUMB_SUPPORT = NO;
|
||||||
|
GCC_VERSION = "";
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SKIP_INSTALL = NO;
|
||||||
|
WK_WEB_VIEW_ONLY = 1;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF5008A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 3047A5111AB8059700498E2A /* build.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = c99;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_THUMB_SUPPORT = NO;
|
||||||
|
GCC_VERSION = "";
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SKIP_INSTALL = NO;
|
||||||
|
WK_WEB_VIEW_ONLY = 1;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Aiber" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
1D6058940D05DD3E006BFB54 /* Debug */,
|
||||||
|
1D6058950D05DD3E006BFB54 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Aiber" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4F08A954540054247B /* Debug */,
|
||||||
|
C01FCF5008A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||||
|
}
|
7
platforms/ios/Aiber.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Aiber.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0730"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
|
||||||
|
BuildableName = "Aiber.app"
|
||||||
|
BlueprintName = "Aiber"
|
||||||
|
ReferencedContainer = "container:Aiber.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
|
||||||
|
BuildableName = "Aiber.app"
|
||||||
|
BlueprintName = "Aiber"
|
||||||
|
ReferencedContainer = "container:Aiber.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
|
||||||
|
BuildableName = "Aiber.app"
|
||||||
|
BlueprintName = "Aiber"
|
||||||
|
ReferencedContainer = "container:Aiber.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
|
||||||
|
BuildableName = "Aiber.app"
|
||||||
|
BlueprintName = "Aiber"
|
||||||
|
ReferencedContainer = "container:Aiber.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
5
platforms/ios/Aiber/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*.mode1v3
|
||||||
|
*.perspectivev3
|
||||||
|
*.pbxuser
|
||||||
|
.DS_Store
|
||||||
|
build/
|
64
platforms/ios/Aiber/Aiber-Info.plist
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en_US</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Aiber</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0.2</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0.2</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSMainNibFile</key>
|
||||||
|
<string/>
|
||||||
|
<key>NSMainNibFile~ipad</key>
|
||||||
|
<string/>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>CDVLaunchScreen</string>
|
||||||
|
<key>UIRequiresFullScreen</key>
|
||||||
|
<true/>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>NSAppTransportSecurity</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExceptionDomains</key>
|
||||||
|
<dict>
|
||||||
|
<key>localhost</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
|
<string>need location access to find things nearby</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
26
platforms/ios/Aiber/Aiber-Prefix.pch
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'Aiber' target in the 'Aiber' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#endif
|
28
platforms/ios/Aiber/Bridging-Header.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Bridging-Header.h
|
||||||
|
// __PROJECT_NAME__
|
||||||
|
//
|
||||||
|
// Created by ___FULLUSERNAME___ on ___DATE___.
|
||||||
|
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cordova/CDV.h>
|
65
platforms/ios/Aiber/CDVLaunchScreen.storyboard
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
|
||||||
|
<capability name="Named colors" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<layoutGuides>
|
||||||
|
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
||||||
|
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||||
|
</layoutGuides>
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchStoryboard" translatesAutoresizingMaskIntoConstraints="NO" id="2ns-9I-Qjs">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
</imageView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" name="BackgroundColor"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="2ns-9I-Qjs" secondAttribute="trailing" id="FZL-3Z-NFz"/>
|
||||||
|
<constraint firstItem="2ns-9I-Qjs" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="L9l-pw-wXj"/>
|
||||||
|
<constraint firstItem="2ns-9I-Qjs" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="oGN-hc-Uzj"/>
|
||||||
|
<constraint firstItem="2ns-9I-Qjs" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="rS9-Wd-zY4"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="LaunchStoryboard" width="1366" height="1366"/>
|
||||||
|
<namedColor name="BackgroundColor">
|
||||||
|
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
</namedColor>
|
||||||
|
</resources>
|
||||||
|
</document>
|
33
platforms/ios/Aiber/Classes/AppDelegate.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// AppDelegate.h
|
||||||
|
// Aiber
|
||||||
|
//
|
||||||
|
// Created by ___FULLUSERNAME___ on ___DATE___.
|
||||||
|
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cordova/CDVViewController.h>
|
||||||
|
#import <Cordova/CDVAppDelegate.h>
|
||||||
|
|
||||||
|
@interface AppDelegate : CDVAppDelegate {}
|
||||||
|
|
||||||
|
@end
|
39
platforms/ios/Aiber/Classes/AppDelegate.m
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// AppDelegate.m
|
||||||
|
// Aiber
|
||||||
|
//
|
||||||
|
// Created by ___FULLUSERNAME___ on ___DATE___.
|
||||||
|
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AppDelegate.h"
|
||||||
|
#import "MainViewController.h"
|
||||||
|
|
||||||
|
@implementation AppDelegate
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
|
||||||
|
{
|
||||||
|
self.viewController = [[MainViewController alloc] init];
|
||||||
|
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
40
platforms/ios/Aiber/Classes/MainViewController.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// MainViewController.h
|
||||||
|
// Aiber
|
||||||
|
//
|
||||||
|
// Created by ___FULLUSERNAME___ on ___DATE___.
|
||||||
|
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cordova/CDVViewController.h>
|
||||||
|
#import <Cordova/CDVCommandDelegateImpl.h>
|
||||||
|
#import <Cordova/CDVCommandQueue.h>
|
||||||
|
|
||||||
|
@interface MainViewController : CDVViewController
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MainCommandDelegate : CDVCommandDelegateImpl
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MainCommandQueue : CDVCommandQueue
|
||||||
|
@end
|
112
platforms/ios/Aiber/Classes/MainViewController.m
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// MainViewController.h
|
||||||
|
// Aiber
|
||||||
|
//
|
||||||
|
// Created by ___FULLUSERNAME___ on ___DATE___.
|
||||||
|
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MainViewController.h"
|
||||||
|
|
||||||
|
@implementation MainViewController
|
||||||
|
|
||||||
|
- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
|
||||||
|
{
|
||||||
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||||
|
if (self) {
|
||||||
|
// Uncomment to override the CDVCommandDelegateImpl used
|
||||||
|
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
|
||||||
|
// Uncomment to override the CDVCommandQueue used
|
||||||
|
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
// Uncomment to override the CDVCommandDelegateImpl used
|
||||||
|
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
|
||||||
|
// Uncomment to override the CDVCommandQueue used
|
||||||
|
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didReceiveMemoryWarning
|
||||||
|
{
|
||||||
|
// Releases the view if it doesn't have a superview.
|
||||||
|
[super didReceiveMemoryWarning];
|
||||||
|
|
||||||
|
// Release any cached data, images, etc that aren't in use.
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark View lifecycle
|
||||||
|
|
||||||
|
- (void)viewWillAppear:(BOOL)animated
|
||||||
|
{
|
||||||
|
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
|
||||||
|
// you can do so here.
|
||||||
|
|
||||||
|
[super viewWillAppear:animated];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLoad
|
||||||
|
{
|
||||||
|
[super viewDidLoad];
|
||||||
|
// Do any additional setup after loading the view from its nib.
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation MainCommandDelegate
|
||||||
|
|
||||||
|
/* To override the methods, uncomment the line in the init function(s)
|
||||||
|
in MainViewController.m
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma mark CDVCommandDelegate implementation
|
||||||
|
|
||||||
|
- (id)getCommandInstance:(NSString*)className
|
||||||
|
{
|
||||||
|
return [super getCommandInstance:className];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)pathForResource:(NSString*)resourcepath
|
||||||
|
{
|
||||||
|
return [super pathForResource:resourcepath];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation MainCommandQueue
|
||||||
|
|
||||||
|
/* To override, uncomment the line in the init function(s)
|
||||||
|
in MainViewController.m
|
||||||
|
*/
|
||||||
|
- (BOOL)execute:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
return [super execute:command];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
138
platforms/ios/Aiber/Classes/MainViewController.xib
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
-->
|
||||||
|
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||||
|
<data>
|
||||||
|
<int key="IBDocument.SystemTarget">1280</int>
|
||||||
|
<string key="IBDocument.SystemVersion">11C25</string>
|
||||||
|
<string key="IBDocument.InterfaceBuilderVersion">1919</string>
|
||||||
|
<string key="IBDocument.AppKitVersion">1138.11</string>
|
||||||
|
<string key="IBDocument.HIToolboxVersion">566.00</string>
|
||||||
|
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||||
|
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||||
|
<string key="NS.object.0">916</string>
|
||||||
|
</object>
|
||||||
|
<array key="IBDocument.IntegratedClassDependencies">
|
||||||
|
<string>IBProxyObject</string>
|
||||||
|
<string>IBUIView</string>
|
||||||
|
</array>
|
||||||
|
<array key="IBDocument.PluginDependencies">
|
||||||
|
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||||
|
</array>
|
||||||
|
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||||
|
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||||
|
<integer value="1" key="NS.object.0"/>
|
||||||
|
</object>
|
||||||
|
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||||
|
<object class="IBProxyObject" id="372490531">
|
||||||
|
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||||
|
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||||
|
</object>
|
||||||
|
<object class="IBProxyObject" id="975951072">
|
||||||
|
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||||
|
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||||
|
</object>
|
||||||
|
<object class="IBUIView" id="191373211">
|
||||||
|
<reference key="NSNextResponder"/>
|
||||||
|
<int key="NSvFlags">274</int>
|
||||||
|
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
|
||||||
|
<reference key="NSSuperview"/>
|
||||||
|
<reference key="NSWindow"/>
|
||||||
|
<object class="NSColor" key="IBUIBackgroundColor">
|
||||||
|
<int key="NSColorSpace">3</int>
|
||||||
|
<bytes key="NSWhite">MQA</bytes>
|
||||||
|
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||||
|
<int key="NSID">2</int>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||||
|
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||||
|
</object>
|
||||||
|
</array>
|
||||||
|
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||||
|
<array class="NSMutableArray" key="connectionRecords">
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||||
|
<string key="label">view</string>
|
||||||
|
<reference key="source" ref="372490531"/>
|
||||||
|
<reference key="destination" ref="191373211"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">3</int>
|
||||||
|
</object>
|
||||||
|
</array>
|
||||||
|
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||||
|
<array key="orderedObjects">
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">0</int>
|
||||||
|
<array key="object" id="0"/>
|
||||||
|
<reference key="children" ref="1000"/>
|
||||||
|
<nil key="parent"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">1</int>
|
||||||
|
<reference key="object" ref="191373211"/>
|
||||||
|
<reference key="parent" ref="0"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">-1</int>
|
||||||
|
<reference key="object" ref="372490531"/>
|
||||||
|
<reference key="parent" ref="0"/>
|
||||||
|
<string key="objectName">File's Owner</string>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">-2</int>
|
||||||
|
<reference key="object" ref="975951072"/>
|
||||||
|
<reference key="parent" ref="0"/>
|
||||||
|
</object>
|
||||||
|
</array>
|
||||||
|
</object>
|
||||||
|
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||||
|
<string key="-1.CustomClassName">MainViewController</string>
|
||||||
|
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||||
|
<string key="-2.CustomClassName">UIResponder</string>
|
||||||
|
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||||
|
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||||
|
</dictionary>
|
||||||
|
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||||
|
<nil key="activeLocalization"/>
|
||||||
|
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||||
|
<nil key="sourceID"/>
|
||||||
|
<int key="maxID">3</int>
|
||||||
|
</object>
|
||||||
|
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||||
|
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||||
|
<object class="IBPartialClassDescription">
|
||||||
|
<string key="className">MainViewController</string>
|
||||||
|
<string key="superclassName">UIViewController</string>
|
||||||
|
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||||
|
<string key="majorKey">IBProjectSource</string>
|
||||||
|
<string key="minorKey">./Classes/MainViewController.h</string>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</array>
|
||||||
|
</object>
|
||||||
|
<int key="IBDocument.localizationMode">0</int>
|
||||||
|
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||||
|
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||||
|
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||||
|
<string key="IBCocoaTouchPluginVersion">916</string>
|
||||||
|
</data>
|
||||||
|
</archive>
|
24
platforms/ios/Aiber/Entitlements-Debug.plist
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
24
platforms/ios/Aiber/Entitlements-Release.plist
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -0,0 +1,241 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-20@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-29.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-29@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-60@2x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "57x57",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "57x57",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-60@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "icon-60@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-20.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-29.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-40.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "50x50",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-50.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "50x50",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-50@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "72x72",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-72.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "72x72",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-72@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-76.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-76@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "83.5x83.5",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "icon-83.5@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "1024x1024",
|
||||||
|
"idiom" : "ios-marketing",
|
||||||
|
"filename" : "icon-1024.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "24x24",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-24@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "notificationCenter",
|
||||||
|
"subtype" : "38mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "27.5x27.5",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-27.5@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "notificationCenter",
|
||||||
|
"subtype" : "42mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-29@2x.png",
|
||||||
|
"role" : "companionSettings",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-29@3x.png",
|
||||||
|
"role" : "companionSettings",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-40@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "appLauncher",
|
||||||
|
"subtype" : "38mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "44x44",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-44@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "appLauncher",
|
||||||
|
"subtype" : "40mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "50x50",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-50@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "appLauncher",
|
||||||
|
"subtype" : "44mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "86x86",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-86@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "quickLook",
|
||||||
|
"subtype" : "38mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "98x98",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"filename" : "icon-98@2x.png",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "quickLook",
|
||||||
|
"subtype" : "42mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "108x108",
|
||||||
|
"idiom" : "watch",
|
||||||
|
"scale" : "2x",
|
||||||
|
"role" : "quickLook",
|
||||||
|
"subtype" : "44mm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "1024x1024",
|
||||||
|
"idiom" : "watch-marketing",
|
||||||
|
"filename" : "icon-1024.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 737 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 6.8 KiB |
BIN
platforms/ios/Aiber/Images.xcassets/AppIcon.appiconset/icon.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"colors": [
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"color": {
|
||||||
|
"platform": "ios",
|
||||||
|
"reference": "systemBackgroundColor"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info": {
|
||||||
|
"author": "Xcode",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
|
}
|
6
platforms/ios/Aiber/Images.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
873
platforms/ios/Aiber/Images.xcassets/LaunchStoryboard.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,873 @@
|
|||||||
|
{
|
||||||
|
"images": [
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "1x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"filename": "Default@2x~universal~anyany.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "2x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "universal",
|
||||||
|
"scale": "3x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "1x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "ipad",
|
||||||
|
"scale": "2x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "1x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "2x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"width-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"height-class": "compact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"height-class": "compact",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "dark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom": "iphone",
|
||||||
|
"scale": "3x",
|
||||||
|
"appearances": [
|
||||||
|
{
|
||||||
|
"appearance": "luminosity",
|
||||||
|
"value": "light"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info": {
|
||||||
|
"author": "Xcode",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
|
}
|
BIN
platforms/ios/Aiber/Images.xcassets/LaunchStoryboard.imageset/Default@2x~universal~anyany.png
vendored
Normal file
After Width: | Height: | Size: 150 KiB |
20
platforms/ios/Aiber/Plugins/README
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
Put the .h and .m files of your plugin here. The .js files of your plugin belong in the www folder.
|
@ -0,0 +1,353 @@
|
|||||||
|
// AFHTTPSessionManager.h
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#if !TARGET_OS_WATCH
|
||||||
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
|
#endif
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
|
||||||
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
|
#else
|
||||||
|
#import <CoreServices/CoreServices.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "AFURLSessionManager.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
|
||||||
|
|
||||||
|
## Subclassing Notes
|
||||||
|
|
||||||
|
Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
|
||||||
|
|
||||||
|
For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect.
|
||||||
|
|
||||||
|
## Methods to Override
|
||||||
|
|
||||||
|
To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`.
|
||||||
|
|
||||||
|
## Serialization
|
||||||
|
|
||||||
|
Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<AFURLRequestSerialization>`.
|
||||||
|
|
||||||
|
Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<AFURLResponseSerialization>`
|
||||||
|
|
||||||
|
## URL Construction Using Relative Paths
|
||||||
|
|
||||||
|
For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`.
|
||||||
|
|
||||||
|
Below are a few examples of how `baseURL` and relative paths interact:
|
||||||
|
|
||||||
|
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
|
||||||
|
[NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
|
||||||
|
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
|
||||||
|
[NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
|
||||||
|
[NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
|
||||||
|
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
|
||||||
|
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
|
||||||
|
|
||||||
|
Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
|
||||||
|
|
||||||
|
@warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies.
|
||||||
|
|
||||||
|
@warning `requestSerializer` must not be `nil`.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
|
||||||
|
|
||||||
|
@warning `responseSerializer` must not be `nil`.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer;
|
||||||
|
|
||||||
|
///---------------------
|
||||||
|
/// @name Initialization
|
||||||
|
///---------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns an `AFHTTPSessionManager` object.
|
||||||
|
*/
|
||||||
|
+ (instancetype)manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes an `AFHTTPSessionManager` object with the specified base URL.
|
||||||
|
|
||||||
|
@param url The base URL for the HTTP client.
|
||||||
|
|
||||||
|
@return The newly-initialized HTTP client
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithBaseURL:(nullable NSURL *)url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes an `AFHTTPSessionManager` object with the specified base URL.
|
||||||
|
|
||||||
|
This is the designated initializer.
|
||||||
|
|
||||||
|
@param url The base URL for the HTTP client.
|
||||||
|
@param configuration The configuration used to create the managed session.
|
||||||
|
|
||||||
|
@return The newly-initialized HTTP client
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithBaseURL:(nullable NSURL *)url
|
||||||
|
sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
///---------------------------
|
||||||
|
/// @name Making HTTP Requests
|
||||||
|
///---------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `GET` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `GET` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `POST` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `POST` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
|
||||||
|
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a multipart request using given HTTP method.
|
||||||
|
|
||||||
|
@param HTTPMethod The HTTP method used to create the request.
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
|
||||||
|
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)uploadTaskWithHTTPMethod:(NSString *)HTTPMethod
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with given HTTP method.
|
||||||
|
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)uploadTaskWithHTTPMethod:(NSString *)HTTPMethod
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and runs an `NSURLSessionDataTask` with a given HTTP method.
|
||||||
|
|
||||||
|
@param HTTPMethod The HTTP method used to create the request.
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded according to the client request serializer.
|
||||||
|
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||||
|
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||||
|
|
||||||
|
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||||
|
*/
|
||||||
|
- (nullable NSURLSessionDataTask *)downloadTaskWithHTTPMethod:(NSString *)HTTPMethod
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,464 @@
|
|||||||
|
// AFHTTPSessionManager.m
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "AFHTTPSessionManager.h"
|
||||||
|
|
||||||
|
#import "AFURLRequestSerialization.h"
|
||||||
|
#import "AFURLResponseSerialization.h"
|
||||||
|
|
||||||
|
#import <Availability.h>
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
#import <Security/Security.h>
|
||||||
|
|
||||||
|
#import <netinet/in.h>
|
||||||
|
#import <netinet6/in6.h>
|
||||||
|
#import <arpa/inet.h>
|
||||||
|
#import <ifaddrs.h>
|
||||||
|
#import <netdb.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_WATCH
|
||||||
|
#import <WatchKit/WatchKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface AFHTTPSessionManager ()
|
||||||
|
@property (readwrite, nonatomic, strong) NSURL *baseURL;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AFHTTPSessionManager
|
||||||
|
@dynamic responseSerializer;
|
||||||
|
|
||||||
|
+ (instancetype)manager {
|
||||||
|
return [[[self class] alloc] initWithBaseURL:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
return [self initWithBaseURL:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithBaseURL:(NSURL *)url {
|
||||||
|
return [self initWithBaseURL:url sessionConfiguration:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
|
||||||
|
return [self initWithBaseURL:nil sessionConfiguration:configuration];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithBaseURL:(NSURL *)url
|
||||||
|
sessionConfiguration:(NSURLSessionConfiguration *)configuration
|
||||||
|
{
|
||||||
|
self = [super initWithSessionConfiguration:configuration];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected
|
||||||
|
if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) {
|
||||||
|
url = [url URLByAppendingPathComponent:@""];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.baseURL = url;
|
||||||
|
|
||||||
|
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||||
|
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (void)setRequestSerializer:(AFHTTPRequestSerializer <AFURLRequestSerialization> *)requestSerializer {
|
||||||
|
NSParameterAssert(requestSerializer);
|
||||||
|
|
||||||
|
_requestSerializer = requestSerializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setResponseSerializer:(AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
|
||||||
|
NSParameterAssert(responseSerializer);
|
||||||
|
|
||||||
|
[super setResponseSerializer:responseSerializer];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
|
||||||
|
return [self GET:URLString parameters:parameters progress:nil success:success failure:failure];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
progress:(void (^)(NSProgress * _Nonnull))downloadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||||
|
{
|
||||||
|
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET"
|
||||||
|
URLString:URLString
|
||||||
|
parameters:parameters
|
||||||
|
uploadProgress:nil
|
||||||
|
downloadProgress:downloadProgress
|
||||||
|
success:success
|
||||||
|
failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)HEAD:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
|
||||||
|
if (success) {
|
||||||
|
success(task);
|
||||||
|
}
|
||||||
|
} failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
return [self POST:URLString parameters:parameters progress:nil success:success failure:failure];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
progress:(void (^)(NSProgress * _Nonnull))uploadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
constructingBodyWithBlock:(nullable void (^)(id<AFMultipartFormData> _Nonnull))block
|
||||||
|
success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||||
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||||
|
{
|
||||||
|
return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
|
||||||
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
|
||||||
|
if (serializationError) {
|
||||||
|
if (failure) {
|
||||||
|
dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||||
|
failure(nil, serializationError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
__block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
if (failure) {
|
||||||
|
failure(task, error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (success) {
|
||||||
|
success(task, responseObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
[task resume];
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
|
||||||
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
|
||||||
|
if (serializationError) {
|
||||||
|
if (failure) {
|
||||||
|
dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||||
|
failure(nil, serializationError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
__block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
if (failure) {
|
||||||
|
failure(task, error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (success) {
|
||||||
|
success(task, responseObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
[task resume];
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)PATCH:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)DELETE:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)uploadTaskWithHTTPMethod:(NSString *)method
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||||
|
{
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
|
||||||
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
|
||||||
|
if (serializationError) {
|
||||||
|
if (failure) {
|
||||||
|
dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||||
|
failure(nil, serializationError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
__block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
if (failure) {
|
||||||
|
failure(task, error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (success) {
|
||||||
|
success(task, responseObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
[task resume];
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)uploadTaskWithHTTPMethod:(NSString *)method
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
progress:(void (^)(NSProgress * _Nonnull))uploadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:method URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
|
||||||
|
|
||||||
|
[dataTask resume];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)downloadTaskWithHTTPMethod:(NSString *)method
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
progress:(nullable void (^)(NSProgress * _Nonnull))downloadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||||
|
{
|
||||||
|
NSURLSessionDataTask *task = [self dataTaskWithHTTPMethod:method URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:downloadProgress success:success failure:failure];
|
||||||
|
|
||||||
|
[task resume];
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(id)parameters
|
||||||
|
uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress
|
||||||
|
downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress
|
||||||
|
success:(void (^)(NSURLSessionDataTask *, id))success
|
||||||
|
failure:(void (^)(NSURLSessionDataTask *, NSError *))failure
|
||||||
|
{
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
|
||||||
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
|
||||||
|
if (serializationError) {
|
||||||
|
if (failure) {
|
||||||
|
dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||||
|
failure(nil, serializationError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
__block NSURLSessionDataTask *dataTask = nil;
|
||||||
|
dataTask = [self dataTaskWithRequest:request
|
||||||
|
uploadProgress:uploadProgress
|
||||||
|
downloadProgress:downloadProgress
|
||||||
|
completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
if (failure) {
|
||||||
|
failure(dataTask, error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (success) {
|
||||||
|
success(dataTask, responseObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
return dataTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSObject
|
||||||
|
|
||||||
|
- (NSString *)description {
|
||||||
|
return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))];
|
||||||
|
NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
|
||||||
|
if (!configuration) {
|
||||||
|
NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"];
|
||||||
|
if (configurationIdentifier) {
|
||||||
|
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100)
|
||||||
|
configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
|
||||||
|
#else
|
||||||
|
configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self = [self initWithBaseURL:baseURL sessionConfiguration:configuration];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
|
||||||
|
self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
|
||||||
|
AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
|
||||||
|
if (decodedPolicy) {
|
||||||
|
self.securityPolicy = decodedPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[super encodeWithCoder:coder];
|
||||||
|
|
||||||
|
[coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))];
|
||||||
|
if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) {
|
||||||
|
[coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
|
||||||
|
} else {
|
||||||
|
[coder encodeObject:self.session.configuration.identifier forKey:@"identifier"];
|
||||||
|
}
|
||||||
|
[coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))];
|
||||||
|
[coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
|
||||||
|
[coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
|
||||||
|
|
||||||
|
HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
|
||||||
|
HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
|
||||||
|
HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone];
|
||||||
|
return HTTPClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,206 @@
|
|||||||
|
// AFNetworkReachabilityManager.h
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#if !TARGET_OS_WATCH
|
||||||
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
|
||||||
|
AFNetworkReachabilityStatusUnknown = -1,
|
||||||
|
AFNetworkReachabilityStatusNotReachable = 0,
|
||||||
|
AFNetworkReachabilityStatusReachableViaWWAN = 1,
|
||||||
|
AFNetworkReachabilityStatusReachableViaWiFi = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
|
||||||
|
|
||||||
|
Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
|
||||||
|
|
||||||
|
See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
|
||||||
|
|
||||||
|
@warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
|
||||||
|
*/
|
||||||
|
@interface AFNetworkReachabilityManager : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
The current network reachability status.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether or not the network is currently reachable.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether or not the network is currently reachable via WWAN.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether or not the network is currently reachable via WiFi.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
|
||||||
|
|
||||||
|
///---------------------
|
||||||
|
/// @name Initialization
|
||||||
|
///---------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the shared network reachability manager.
|
||||||
|
*/
|
||||||
|
+ (instancetype)sharedManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a network reachability manager with the default socket address.
|
||||||
|
|
||||||
|
@return An initialized network reachability manager, actively monitoring the default socket address.
|
||||||
|
*/
|
||||||
|
+ (instancetype)manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a network reachability manager for the specified domain.
|
||||||
|
|
||||||
|
@param domain The domain used to evaluate network reachability.
|
||||||
|
|
||||||
|
@return An initialized network reachability manager, actively monitoring the specified domain.
|
||||||
|
*/
|
||||||
|
+ (instancetype)managerForDomain:(NSString *)domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a network reachability manager for the socket address.
|
||||||
|
|
||||||
|
@param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
|
||||||
|
|
||||||
|
@return An initialized network reachability manager, actively monitoring the specified socket address.
|
||||||
|
*/
|
||||||
|
+ (instancetype)managerForAddress:(const void *)address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes an instance of a network reachability manager from the specified reachability object.
|
||||||
|
|
||||||
|
@param reachability The reachability object to monitor.
|
||||||
|
|
||||||
|
@return An initialized network reachability manager, actively monitoring the specified reachability.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
///--------------------------------------------------
|
||||||
|
/// @name Starting & Stopping Reachability Monitoring
|
||||||
|
///--------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Starts monitoring for changes in network reachability status.
|
||||||
|
*/
|
||||||
|
- (void)startMonitoring;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Stops monitoring for changes in network reachability status.
|
||||||
|
*/
|
||||||
|
- (void)stopMonitoring;
|
||||||
|
|
||||||
|
///-------------------------------------------------
|
||||||
|
/// @name Getting Localized Reachability Description
|
||||||
|
///-------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a localized string representation of the current network reachability status.
|
||||||
|
*/
|
||||||
|
- (NSString *)localizedNetworkReachabilityStatusString;
|
||||||
|
|
||||||
|
///---------------------------------------------------
|
||||||
|
/// @name Setting Network Reachability Change Callback
|
||||||
|
///---------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a callback to be executed when the network availability of the `baseURL` host changes.
|
||||||
|
|
||||||
|
@param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
|
||||||
|
*/
|
||||||
|
- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
///----------------
|
||||||
|
/// @name Constants
|
||||||
|
///----------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
## Network Reachability
|
||||||
|
|
||||||
|
The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AFNetworkReachabilityStatusUnknown,
|
||||||
|
AFNetworkReachabilityStatusNotReachable,
|
||||||
|
AFNetworkReachabilityStatusReachableViaWWAN,
|
||||||
|
AFNetworkReachabilityStatusReachableViaWiFi,
|
||||||
|
}
|
||||||
|
|
||||||
|
`AFNetworkReachabilityStatusUnknown`
|
||||||
|
The `baseURL` host reachability is not known.
|
||||||
|
|
||||||
|
`AFNetworkReachabilityStatusNotReachable`
|
||||||
|
The `baseURL` host cannot be reached.
|
||||||
|
|
||||||
|
`AFNetworkReachabilityStatusReachableViaWWAN`
|
||||||
|
The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
|
||||||
|
|
||||||
|
`AFNetworkReachabilityStatusReachableViaWiFi`
|
||||||
|
The `baseURL` host can be reached via a Wi-Fi connection.
|
||||||
|
|
||||||
|
### Keys for Notification UserInfo Dictionary
|
||||||
|
|
||||||
|
Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
|
||||||
|
|
||||||
|
`AFNetworkingReachabilityNotificationStatusItem`
|
||||||
|
A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
|
||||||
|
The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
|
||||||
|
*/
|
||||||
|
|
||||||
|
///--------------------
|
||||||
|
/// @name Notifications
|
||||||
|
///--------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posted when network reachability changes.
|
||||||
|
This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
|
||||||
|
|
||||||
|
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
|
||||||
|
|
||||||
|
///--------------------
|
||||||
|
/// @name Functions
|
||||||
|
///--------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
#endif
|
@ -0,0 +1,263 @@
|
|||||||
|
// AFNetworkReachabilityManager.m
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "AFNetworkReachabilityManager.h"
|
||||||
|
#if !TARGET_OS_WATCH
|
||||||
|
|
||||||
|
#import <netinet/in.h>
|
||||||
|
#import <netinet6/in6.h>
|
||||||
|
#import <arpa/inet.h>
|
||||||
|
#import <ifaddrs.h>
|
||||||
|
#import <netdb.h>
|
||||||
|
|
||||||
|
NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
|
||||||
|
NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
|
||||||
|
|
||||||
|
typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
|
||||||
|
|
||||||
|
NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
|
||||||
|
switch (status) {
|
||||||
|
case AFNetworkReachabilityStatusNotReachable:
|
||||||
|
return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
|
||||||
|
case AFNetworkReachabilityStatusReachableViaWWAN:
|
||||||
|
return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
|
||||||
|
case AFNetworkReachabilityStatusReachableViaWiFi:
|
||||||
|
return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
|
||||||
|
case AFNetworkReachabilityStatusUnknown:
|
||||||
|
default:
|
||||||
|
return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) {
|
||||||
|
BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
|
||||||
|
BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
|
||||||
|
BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
|
||||||
|
BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
|
||||||
|
BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
|
||||||
|
|
||||||
|
AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
|
||||||
|
if (isNetworkReachable == NO) {
|
||||||
|
status = AFNetworkReachabilityStatusNotReachable;
|
||||||
|
}
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
|
||||||
|
status = AFNetworkReachabilityStatusReachableViaWWAN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
status = AFNetworkReachabilityStatusReachableViaWiFi;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue a status change notification for the main thread.
|
||||||
|
*
|
||||||
|
* This is done to ensure that the notifications are received in the same order
|
||||||
|
* as they are sent. If notifications are sent directly, it is possible that
|
||||||
|
* a queued notification (for an earlier status condition) is processed after
|
||||||
|
* the later update, resulting in the listener being left in the wrong state.
|
||||||
|
*/
|
||||||
|
static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) {
|
||||||
|
AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (block) {
|
||||||
|
block(status);
|
||||||
|
}
|
||||||
|
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||||
|
NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
|
||||||
|
[notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
|
||||||
|
AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const void * AFNetworkReachabilityRetainCallback(const void *info) {
|
||||||
|
return Block_copy(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
||||||
|
if (info) {
|
||||||
|
Block_release(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@interface AFNetworkReachabilityManager ()
|
||||||
|
@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
|
||||||
|
@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
|
||||||
|
@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AFNetworkReachabilityManager
|
||||||
|
|
||||||
|
+ (instancetype)sharedManager {
|
||||||
|
static AFNetworkReachabilityManager *_sharedManager = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
_sharedManager = [self manager];
|
||||||
|
});
|
||||||
|
|
||||||
|
return _sharedManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)managerForDomain:(NSString *)domain {
|
||||||
|
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
|
||||||
|
|
||||||
|
AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
|
||||||
|
|
||||||
|
CFRelease(reachability);
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)managerForAddress:(const void *)address {
|
||||||
|
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
|
||||||
|
AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
|
||||||
|
|
||||||
|
CFRelease(reachability);
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)manager
|
||||||
|
{
|
||||||
|
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
|
||||||
|
struct sockaddr_in6 address;
|
||||||
|
bzero(&address, sizeof(address));
|
||||||
|
address.sin6_len = sizeof(address);
|
||||||
|
address.sin6_family = AF_INET6;
|
||||||
|
#else
|
||||||
|
struct sockaddr_in address;
|
||||||
|
bzero(&address, sizeof(address));
|
||||||
|
address.sin_len = sizeof(address);
|
||||||
|
address.sin_family = AF_INET;
|
||||||
|
#endif
|
||||||
|
return [self managerForAddress:&address];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
_networkReachability = CFRetain(reachability);
|
||||||
|
self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self stopMonitoring];
|
||||||
|
|
||||||
|
if (_networkReachability != NULL) {
|
||||||
|
CFRelease(_networkReachability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (BOOL)isReachable {
|
||||||
|
return [self isReachableViaWWAN] || [self isReachableViaWiFi];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isReachableViaWWAN {
|
||||||
|
return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isReachableViaWiFi {
|
||||||
|
return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (void)startMonitoring {
|
||||||
|
[self stopMonitoring];
|
||||||
|
|
||||||
|
if (!self.networkReachability) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
__weak __typeof(self)weakSelf = self;
|
||||||
|
AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
|
||||||
|
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||||
|
|
||||||
|
strongSelf.networkReachabilityStatus = status;
|
||||||
|
if (strongSelf.networkReachabilityStatusBlock) {
|
||||||
|
strongSelf.networkReachabilityStatusBlock(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
|
||||||
|
SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
|
||||||
|
SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
|
||||||
|
SCNetworkReachabilityFlags flags;
|
||||||
|
if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) {
|
||||||
|
AFPostReachabilityStatusChange(flags, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)stopMonitoring {
|
||||||
|
if (!self.networkReachability) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (NSString *)localizedNetworkReachabilityStatusString {
|
||||||
|
return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
|
||||||
|
self.networkReachabilityStatusBlock = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSKeyValueObserving
|
||||||
|
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
|
||||||
|
if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
|
||||||
|
return [NSSet setWithObject:@"networkReachabilityStatus"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [super keyPathsForValuesAffectingValueForKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
#endif
|
@ -0,0 +1,41 @@
|
|||||||
|
// AFNetworking.h
|
||||||
|
//
|
||||||
|
// Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Availability.h>
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#ifndef _AFNETWORKING_
|
||||||
|
#define _AFNETWORKING_
|
||||||
|
|
||||||
|
#import "AFURLRequestSerialization.h"
|
||||||
|
#import "AFURLResponseSerialization.h"
|
||||||
|
#import "AFSecurityPolicy.h"
|
||||||
|
|
||||||
|
#if !TARGET_OS_WATCH
|
||||||
|
#import "AFNetworkReachabilityManager.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "AFURLSessionManager.h"
|
||||||
|
#import "AFHTTPSessionManager.h"
|
||||||
|
|
||||||
|
#endif /* _AFNETWORKING_ */
|
@ -0,0 +1,154 @@
|
|||||||
|
// AFSecurityPolicy.h
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Security/Security.h>
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
|
||||||
|
AFSSLPinningModeNone,
|
||||||
|
AFSSLPinningModePublicKey,
|
||||||
|
AFSSLPinningModeCertificate,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
|
||||||
|
|
||||||
|
Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface AFSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The certificates used to evaluate server trust according to the SSL pinning mode.
|
||||||
|
|
||||||
|
By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
||||||
|
|
||||||
|
Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong, nullable) NSSet <NSData *> *pinnedCertificates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL allowInvalidCertificates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL validatesDomainName;
|
||||||
|
|
||||||
|
///-----------------------------------------
|
||||||
|
/// @name Getting Certificates from the Bundle
|
||||||
|
///-----------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
||||||
|
|
||||||
|
@return The certificates included in the given bundle.
|
||||||
|
*/
|
||||||
|
+ (NSSet <NSData *> *)certificatesInBundle:(NSBundle *)bundle;
|
||||||
|
|
||||||
|
///-----------------------------------------
|
||||||
|
/// @name Getting Specific Security Policies
|
||||||
|
///-----------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
|
||||||
|
|
||||||
|
@return The default security policy.
|
||||||
|
*/
|
||||||
|
+ (instancetype)defaultPolicy;
|
||||||
|
|
||||||
|
///---------------------
|
||||||
|
/// @name Initialization
|
||||||
|
///---------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a security policy with the specified pinning mode.
|
||||||
|
|
||||||
|
@param pinningMode The SSL pinning mode.
|
||||||
|
|
||||||
|
@return A new security policy.
|
||||||
|
*/
|
||||||
|
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a security policy with the specified pinning mode.
|
||||||
|
|
||||||
|
@param pinningMode The SSL pinning mode.
|
||||||
|
@param pinnedCertificates The certificates to pin against.
|
||||||
|
|
||||||
|
@return A new security policy.
|
||||||
|
*/
|
||||||
|
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet <NSData *> *)pinnedCertificates;
|
||||||
|
|
||||||
|
///------------------------------
|
||||||
|
/// @name Evaluating Server Trust
|
||||||
|
///------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether or not the specified server trust should be accepted, based on the security policy.
|
||||||
|
|
||||||
|
This method should be used when responding to an authentication challenge from a server.
|
||||||
|
|
||||||
|
@param serverTrust The X.509 certificate trust of the server.
|
||||||
|
@param domain The domain of serverTrust. If `nil`, the domain will not be validated.
|
||||||
|
|
||||||
|
@return Whether or not to trust the server.
|
||||||
|
*/
|
||||||
|
- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
|
||||||
|
forDomain:(nullable NSString *)domain;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
|
///----------------
|
||||||
|
/// @name Constants
|
||||||
|
///----------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
## SSL Pinning Modes
|
||||||
|
|
||||||
|
The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AFSSLPinningModeNone,
|
||||||
|
AFSSLPinningModePublicKey,
|
||||||
|
AFSSLPinningModeCertificate,
|
||||||
|
}
|
||||||
|
|
||||||
|
`AFSSLPinningModeNone`
|
||||||
|
Do not used pinned certificates to validate servers.
|
||||||
|
|
||||||
|
`AFSSLPinningModePublicKey`
|
||||||
|
Validate host certificates against public keys of pinned certificates.
|
||||||
|
|
||||||
|
`AFSSLPinningModeCertificate`
|
||||||
|
Validate host certificates against pinned certificates.
|
||||||
|
*/
|
@ -0,0 +1,353 @@
|
|||||||
|
// AFSecurityPolicy.m
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "AFSecurityPolicy.h"
|
||||||
|
|
||||||
|
#import <AssertMacros.h>
|
||||||
|
|
||||||
|
#if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV
|
||||||
|
static NSData * AFSecKeyGetData(SecKeyRef key) {
|
||||||
|
CFDataRef data = NULL;
|
||||||
|
|
||||||
|
__Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out);
|
||||||
|
|
||||||
|
return (__bridge_transfer NSData *)data;
|
||||||
|
|
||||||
|
_out:
|
||||||
|
if (data) {
|
||||||
|
CFRelease(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) {
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
|
||||||
|
return [(__bridge id)key1 isEqual:(__bridge id)key2];
|
||||||
|
#else
|
||||||
|
return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static id AFPublicKeyForCertificate(NSData *certificate) {
|
||||||
|
id allowedPublicKey = nil;
|
||||||
|
SecCertificateRef allowedCertificate;
|
||||||
|
SecCertificateRef allowedCertificates[1];
|
||||||
|
CFArrayRef tempCertificates = nil;
|
||||||
|
SecPolicyRef policy = nil;
|
||||||
|
SecTrustRef allowedTrust = nil;
|
||||||
|
SecTrustResultType result;
|
||||||
|
|
||||||
|
allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate);
|
||||||
|
__Require_Quiet(allowedCertificate != NULL, _out);
|
||||||
|
|
||||||
|
allowedCertificates[0] = allowedCertificate;
|
||||||
|
tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL);
|
||||||
|
|
||||||
|
policy = SecPolicyCreateBasicX509();
|
||||||
|
__Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out);
|
||||||
|
__Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out);
|
||||||
|
|
||||||
|
allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust);
|
||||||
|
|
||||||
|
_out:
|
||||||
|
if (allowedTrust) {
|
||||||
|
CFRelease(allowedTrust);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (policy) {
|
||||||
|
CFRelease(policy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempCertificates) {
|
||||||
|
CFRelease(tempCertificates);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowedCertificate) {
|
||||||
|
CFRelease(allowedCertificate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowedPublicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) {
|
||||||
|
BOOL isValid = NO;
|
||||||
|
SecTrustResultType result;
|
||||||
|
__Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out);
|
||||||
|
|
||||||
|
isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed);
|
||||||
|
|
||||||
|
_out:
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||||
|
CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
|
||||||
|
NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
|
||||||
|
|
||||||
|
for (CFIndex i = 0; i < certificateCount; i++) {
|
||||||
|
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
|
||||||
|
[trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [NSArray arrayWithArray:trustChain];
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||||
|
SecPolicyRef policy = SecPolicyCreateBasicX509();
|
||||||
|
CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
|
||||||
|
NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
|
||||||
|
for (CFIndex i = 0; i < certificateCount; i++) {
|
||||||
|
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
|
||||||
|
|
||||||
|
SecCertificateRef someCertificates[] = {certificate};
|
||||||
|
CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL);
|
||||||
|
|
||||||
|
SecTrustRef trust;
|
||||||
|
__Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out);
|
||||||
|
|
||||||
|
SecTrustResultType result;
|
||||||
|
__Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out);
|
||||||
|
|
||||||
|
[trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
|
||||||
|
|
||||||
|
_out:
|
||||||
|
if (trust) {
|
||||||
|
CFRelease(trust);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (certificates) {
|
||||||
|
CFRelease(certificates);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CFRelease(policy);
|
||||||
|
|
||||||
|
return [NSArray arrayWithArray:trustChain];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@interface AFSecurityPolicy()
|
||||||
|
@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
|
||||||
|
@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AFSecurityPolicy
|
||||||
|
|
||||||
|
+ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
|
||||||
|
NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"www/certificates"];
|
||||||
|
NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]];
|
||||||
|
|
||||||
|
for (NSString *path in paths) {
|
||||||
|
NSData *certificateData = [NSData dataWithContentsOfFile:path];
|
||||||
|
[certificates addObject:certificateData];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [NSSet setWithSet:certificates];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSSet *)defaultPinnedCertificates {
|
||||||
|
static NSSet *_defaultPinnedCertificates = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||||
|
_defaultPinnedCertificates = [self certificatesInBundle:bundle];
|
||||||
|
});
|
||||||
|
|
||||||
|
return _defaultPinnedCertificates;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)defaultPolicy {
|
||||||
|
AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
||||||
|
securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
|
||||||
|
|
||||||
|
return securityPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode {
|
||||||
|
return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
|
||||||
|
AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
||||||
|
securityPolicy.SSLPinningMode = pinningMode;
|
||||||
|
|
||||||
|
[securityPolicy setPinnedCertificates:pinnedCertificates];
|
||||||
|
|
||||||
|
return securityPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.validatesDomainName = YES;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPinnedCertificates:(NSSet *)pinnedCertificates {
|
||||||
|
_pinnedCertificates = pinnedCertificates;
|
||||||
|
|
||||||
|
if (self.pinnedCertificates) {
|
||||||
|
NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]];
|
||||||
|
for (NSData *certificate in self.pinnedCertificates) {
|
||||||
|
id publicKey = AFPublicKeyForCertificate(certificate);
|
||||||
|
if (!publicKey) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
[mutablePinnedPublicKeys addObject:publicKey];
|
||||||
|
}
|
||||||
|
self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys];
|
||||||
|
} else {
|
||||||
|
self.pinnedPublicKeys = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
|
||||||
|
forDomain:(NSString *)domain
|
||||||
|
{
|
||||||
|
if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) {
|
||||||
|
// https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html
|
||||||
|
// According to the docs, you should only trust your provided certs for evaluation.
|
||||||
|
// Pinned certificates are added to the trust. Without pinned certificates,
|
||||||
|
// there is nothing to evaluate against.
|
||||||
|
//
|
||||||
|
// From Apple Docs:
|
||||||
|
// "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors).
|
||||||
|
// Instead, add your own (self-signed) CA certificate to the list of trusted anchors."
|
||||||
|
NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning.");
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *policies = [NSMutableArray array];
|
||||||
|
if (self.validatesDomainName) {
|
||||||
|
[policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
|
||||||
|
} else {
|
||||||
|
[policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
|
||||||
|
}
|
||||||
|
|
||||||
|
SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
|
||||||
|
|
||||||
|
if (self.SSLPinningMode == AFSSLPinningModeNone) {
|
||||||
|
return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust);
|
||||||
|
} else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (self.SSLPinningMode) {
|
||||||
|
case AFSSLPinningModeNone:
|
||||||
|
default:
|
||||||
|
return NO;
|
||||||
|
case AFSSLPinningModeCertificate: {
|
||||||
|
NSMutableArray *pinnedCertificates = [NSMutableArray array];
|
||||||
|
for (NSData *certificateData in self.pinnedCertificates) {
|
||||||
|
[pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
|
||||||
|
}
|
||||||
|
SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
|
||||||
|
|
||||||
|
if (!AFServerTrustIsValid(serverTrust)) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA)
|
||||||
|
NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);
|
||||||
|
|
||||||
|
for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) {
|
||||||
|
if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
case AFSSLPinningModePublicKey: {
|
||||||
|
NSUInteger trustedPublicKeyCount = 0;
|
||||||
|
NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust);
|
||||||
|
|
||||||
|
for (id trustChainPublicKey in publicKeys) {
|
||||||
|
for (id pinnedPublicKey in self.pinnedPublicKeys) {
|
||||||
|
if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
|
||||||
|
trustedPublicKeyCount += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trustedPublicKeyCount > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSKeyValueObserving
|
||||||
|
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys {
|
||||||
|
return [NSSet setWithObject:@"pinnedCertificates"];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
|
||||||
|
self = [self init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue];
|
||||||
|
self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
|
||||||
|
self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))];
|
||||||
|
self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))];
|
||||||
|
[coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
|
||||||
|
[coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))];
|
||||||
|
[coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
|
||||||
|
securityPolicy.SSLPinningMode = self.SSLPinningMode;
|
||||||
|
securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
|
||||||
|
securityPolicy.validatesDomainName = self.validatesDomainName;
|
||||||
|
securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone];
|
||||||
|
|
||||||
|
return securityPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,479 @@
|
|||||||
|
// AFURLRequestSerialization.h
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_WATCH
|
||||||
|
#import <WatchKit/WatchKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a percent-escaped string following RFC 3986 for a query string key or value.
|
||||||
|
RFC 3986 states that the following characters are "reserved" characters.
|
||||||
|
- General Delimiters: ":", "#", "[", "]", "@", "?", "/"
|
||||||
|
- Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
|
||||||
|
|
||||||
|
In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
|
||||||
|
query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
|
||||||
|
should be percent-escaped in the query string.
|
||||||
|
|
||||||
|
@param string The string to be percent-escaped.
|
||||||
|
|
||||||
|
@return The percent-escaped string.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string);
|
||||||
|
|
||||||
|
/**
|
||||||
|
A helper method to generate encoded url query parameters for appending to the end of a URL.
|
||||||
|
|
||||||
|
@param parameters A dictionary of key/values to be encoded.
|
||||||
|
|
||||||
|
@return A url encoded query string
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
|
||||||
|
|
||||||
|
/**
|
||||||
|
The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
|
||||||
|
|
||||||
|
For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
|
||||||
|
*/
|
||||||
|
@protocol AFURLRequestSerialization <NSObject, NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a request with the specified parameters encoded into a copy of the original request.
|
||||||
|
|
||||||
|
@param request The original request.
|
||||||
|
@param parameters The parameters to be encoded.
|
||||||
|
@param error The error that occurred while attempting to encode the request parameters.
|
||||||
|
|
||||||
|
@return A serialized request.
|
||||||
|
*/
|
||||||
|
- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
|
withParameters:(nullable id)parameters
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
|
||||||
|
AFHTTPRequestQueryStringDefaultStyle = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
@protocol AFMultipartFormData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
||||||
|
|
||||||
|
Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior.
|
||||||
|
*/
|
||||||
|
@interface AFHTTPRequestSerializer : NSObject <AFURLRequestSerialization>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSStringEncoding stringEncoding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether created requests can use the device’s cellular radio (if present). `YES` by default.
|
||||||
|
|
||||||
|
@see NSMutableURLRequest -setAllowsCellularAccess:
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL allowsCellularAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default.
|
||||||
|
|
||||||
|
@see NSMutableURLRequest -setCachePolicy:
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether created requests should use the default cookie handling. `YES` by default.
|
||||||
|
|
||||||
|
@see NSMutableURLRequest -setHTTPShouldHandleCookies:
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL HTTPShouldHandleCookies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default
|
||||||
|
|
||||||
|
@see NSMutableURLRequest -setHTTPShouldUsePipelining:
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL HTTPShouldUsePipelining;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default.
|
||||||
|
|
||||||
|
@see NSMutableURLRequest -setNetworkServiceType:
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds.
|
||||||
|
|
||||||
|
@see NSMutableURLRequest -setTimeoutInterval:
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||||
|
|
||||||
|
///---------------------------------------
|
||||||
|
/// @name Configuring HTTP Request Headers
|
||||||
|
///---------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Default HTTP header field values to be applied to serialized requests. By default, these include the following:
|
||||||
|
|
||||||
|
- `Accept-Language` with the contents of `NSLocale +preferredLanguages`
|
||||||
|
- `User-Agent` with the contents of various bundle identifiers and OS designations
|
||||||
|
|
||||||
|
@discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSDictionary <NSString *, NSString *> *HTTPRequestHeaders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a serializer with default configuration.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
|
||||||
|
|
||||||
|
@param field The HTTP header to set a default value for
|
||||||
|
@param value The value set as default for the specified header, or `nil`
|
||||||
|
*/
|
||||||
|
- (void)setValue:(nullable NSString *)value
|
||||||
|
forHTTPHeaderField:(NSString *)field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the value for the HTTP headers set in the request serializer.
|
||||||
|
|
||||||
|
@param field The HTTP header to retrieve the default value for
|
||||||
|
|
||||||
|
@return The value set as default for the specified header, or `nil`
|
||||||
|
*/
|
||||||
|
- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
|
||||||
|
|
||||||
|
@param username The HTTP basic auth username
|
||||||
|
@param password The HTTP basic auth password
|
||||||
|
*/
|
||||||
|
- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
|
||||||
|
password:(NSString *)password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Clears any existing value for the "Authorization" HTTP header.
|
||||||
|
*/
|
||||||
|
- (void)clearAuthorizationHeader;
|
||||||
|
|
||||||
|
///-------------------------------------------------------
|
||||||
|
/// @name Configuring Query String Parameter Serialization
|
||||||
|
///-------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) NSSet <NSString *> *HTTPMethodsEncodingParametersInURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the method of query string serialization according to one of the pre-defined styles.
|
||||||
|
|
||||||
|
@param style The serialization style.
|
||||||
|
|
||||||
|
@see AFHTTPRequestQueryStringSerializationStyle
|
||||||
|
*/
|
||||||
|
- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the a custom method of query string serialization according to the specified block.
|
||||||
|
|
||||||
|
@param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request.
|
||||||
|
*/
|
||||||
|
- (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block;
|
||||||
|
|
||||||
|
///-------------------------------
|
||||||
|
/// @name Creating Request Objects
|
||||||
|
///-------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string.
|
||||||
|
|
||||||
|
If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
|
||||||
|
|
||||||
|
@param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
|
||||||
|
@param error The error that occurred while constructing the request.
|
||||||
|
|
||||||
|
@return An `NSMutableURLRequest` object.
|
||||||
|
*/
|
||||||
|
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(nullable id)parameters
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
|
||||||
|
|
||||||
|
Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
|
||||||
|
|
||||||
|
@param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
|
||||||
|
@param URLString The URL string used to create the request URL.
|
||||||
|
@param parameters The parameters to be encoded and set in the request HTTP body.
|
||||||
|
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
|
||||||
|
@param error The error that occurred while constructing the request.
|
||||||
|
|
||||||
|
@return An `NSMutableURLRequest` object
|
||||||
|
*/
|
||||||
|
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
|
||||||
|
URLString:(NSString *)URLString
|
||||||
|
parameters:(nullable NSDictionary <NSString *, id> *)parameters
|
||||||
|
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished.
|
||||||
|
|
||||||
|
@param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`.
|
||||||
|
@param fileURL The file URL to write multipart form contents to.
|
||||||
|
@param handler A handler block to execute.
|
||||||
|
|
||||||
|
@discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
|
||||||
|
|
||||||
|
@see https://github.com/AFNetworking/AFNetworking/issues/1398
|
||||||
|
*/
|
||||||
|
- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
|
||||||
|
writingStreamContentsToFile:(NSURL *)fileURL
|
||||||
|
completionHandler:(nullable void (^)(NSError * _Nullable error))handler;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`.
|
||||||
|
*/
|
||||||
|
@protocol AFMultipartFormData
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||||
|
|
||||||
|
The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
|
||||||
|
|
||||||
|
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
||||||
|
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||||
|
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||||
|
|
||||||
|
@return `YES` if the file data was successfully appended, otherwise `NO`.
|
||||||
|
*/
|
||||||
|
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
||||||
|
name:(NSString *)name
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||||
|
|
||||||
|
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
||||||
|
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||||
|
@param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
|
||||||
|
@param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
|
||||||
|
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||||
|
|
||||||
|
@return `YES` if the file data was successfully appended otherwise `NO`.
|
||||||
|
*/
|
||||||
|
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
||||||
|
name:(NSString *)name
|
||||||
|
fileName:(NSString *)fileName
|
||||||
|
mimeType:(NSString *)mimeType
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
|
||||||
|
|
||||||
|
@param inputStream The input stream to be appended to the form data
|
||||||
|
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
|
||||||
|
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
|
||||||
|
@param length The length of the specified input stream in bytes.
|
||||||
|
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||||
|
*/
|
||||||
|
- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream
|
||||||
|
name:(NSString *)name
|
||||||
|
fileName:(NSString *)fileName
|
||||||
|
length:(int64_t)length
|
||||||
|
mimeType:(NSString *)mimeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
||||||
|
|
||||||
|
@param data The data to be encoded and appended to the form data.
|
||||||
|
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||||
|
@param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
|
||||||
|
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
||||||
|
*/
|
||||||
|
- (void)appendPartWithFileData:(NSData *)data
|
||||||
|
name:(NSString *)name
|
||||||
|
fileName:(NSString *)fileName
|
||||||
|
mimeType:(NSString *)mimeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
|
||||||
|
|
||||||
|
@param data The data to be encoded and appended to the form data.
|
||||||
|
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (void)appendPartWithFormData:(NSData *)data
|
||||||
|
name:(NSString *)name;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends HTTP headers, followed by the encoded data and the multipart form boundary.
|
||||||
|
|
||||||
|
@param headers The HTTP headers to be appended to the form data.
|
||||||
|
@param body The data to be encoded and appended to the form data. This parameter must not be `nil`.
|
||||||
|
*/
|
||||||
|
- (void)appendPartWithHeaders:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||||
|
body:(NSData *)body;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
|
||||||
|
|
||||||
|
When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
|
||||||
|
|
||||||
|
@param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb.
|
||||||
|
@param delay Duration of delay each time a packet is read. By default, no delay is set.
|
||||||
|
*/
|
||||||
|
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
|
||||||
|
delay:(NSTimeInterval)delay;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
|
||||||
|
*/
|
||||||
|
@interface AFJSONRequestSerializer : AFHTTPRequestSerializer
|
||||||
|
|
||||||
|
/**
|
||||||
|
Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSJSONWritingOptions writingOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a JSON serializer with specified reading and writing options.
|
||||||
|
|
||||||
|
@param writingOptions The specified JSON writing options.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`.
|
||||||
|
*/
|
||||||
|
@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property list format. Possible values are described in "NSPropertyListFormat".
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSPropertyListFormat format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@warning The `writeOptions` property is currently unused.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a property list serializer with a specified format, read options, and write options.
|
||||||
|
|
||||||
|
@param format The property list format.
|
||||||
|
@param writeOptions The property list write options.
|
||||||
|
|
||||||
|
@warning The `writeOptions` property is currently unused.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
|
||||||
|
writeOptions:(NSPropertyListWriteOptions)writeOptions;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
///----------------
|
||||||
|
/// @name Constants
|
||||||
|
///----------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
## Error Domains
|
||||||
|
|
||||||
|
The following error domain is predefined.
|
||||||
|
|
||||||
|
- `NSString * const AFURLRequestSerializationErrorDomain`
|
||||||
|
|
||||||
|
### Constants
|
||||||
|
|
||||||
|
`AFURLRequestSerializationErrorDomain`
|
||||||
|
AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
## User info dictionary keys
|
||||||
|
|
||||||
|
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||||
|
|
||||||
|
- `NSString * const AFNetworkingOperationFailingURLRequestErrorKey`
|
||||||
|
|
||||||
|
### Constants
|
||||||
|
|
||||||
|
`AFNetworkingOperationFailingURLRequestErrorKey`
|
||||||
|
The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
## Throttling Bandwidth for HTTP Request Input Streams
|
||||||
|
|
||||||
|
@see -throttleBandwidthWithPacketSize:delay:
|
||||||
|
|
||||||
|
### Constants
|
||||||
|
|
||||||
|
`kAFUploadStream3GSuggestedPacketSize`
|
||||||
|
Maximum packet size, in number of bytes. Equal to 16kb.
|
||||||
|
|
||||||
|
`kAFUploadStream3GSuggestedDelay`
|
||||||
|
Duration of delay each time a packet is read. Equal to 0.2 seconds.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize;
|
||||||
|
FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,318 @@
|
|||||||
|
// AFURLResponseSerialization.h
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
|
||||||
|
|
||||||
|
For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
|
||||||
|
*/
|
||||||
|
@protocol AFURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The response object decoded from the data associated with a specified response.
|
||||||
|
|
||||||
|
@param response The response to be processed.
|
||||||
|
@param data The response data to be decoded.
|
||||||
|
@param error The error that occurred while attempting to decode the response data.
|
||||||
|
|
||||||
|
@return The object decoded from the specified response data.
|
||||||
|
*/
|
||||||
|
- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
|
||||||
|
data:(nullable NSData *)data
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
|
||||||
|
|
||||||
|
Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
|
||||||
|
*/
|
||||||
|
@interface AFHTTPResponseSerializer : NSObject <AFURLResponseSerialization>
|
||||||
|
|
||||||
|
- (instancetype)init;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSStringEncoding stringEncoding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a serializer with default configuration.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializer;
|
||||||
|
|
||||||
|
///-----------------------------------------
|
||||||
|
/// @name Configuring Response Serialization
|
||||||
|
///-----------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation.
|
||||||
|
|
||||||
|
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, nullable) NSSet <NSString *> *acceptableContentTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Validates the specified response and data.
|
||||||
|
|
||||||
|
In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
|
||||||
|
|
||||||
|
@param response The response to be validated.
|
||||||
|
@param data The data associated with the response.
|
||||||
|
@param error The error that occurred while attempting to validate the response.
|
||||||
|
|
||||||
|
@return `YES` if the response is valid, otherwise `NO`.
|
||||||
|
*/
|
||||||
|
- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response
|
||||||
|
data:(nullable NSData *)data
|
||||||
|
error:(NSError * _Nullable __autoreleasing *)error;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses.
|
||||||
|
|
||||||
|
By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
|
||||||
|
|
||||||
|
- `application/json`
|
||||||
|
- `text/json`
|
||||||
|
- `text/javascript`
|
||||||
|
*/
|
||||||
|
@interface AFJSONResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
- (instancetype)init;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSJSONReadingOptions readingOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL removesKeysWithNullValues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a JSON serializer with specified reading and writing options.
|
||||||
|
|
||||||
|
@param readingOptions The specified JSON reading options.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects.
|
||||||
|
|
||||||
|
By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
|
||||||
|
|
||||||
|
- `application/xml`
|
||||||
|
- `text/xml`
|
||||||
|
*/
|
||||||
|
@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
|
||||||
|
|
||||||
|
By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
|
||||||
|
|
||||||
|
- `application/xml`
|
||||||
|
- `text/xml`
|
||||||
|
*/
|
||||||
|
@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
- (instancetype)init;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSUInteger options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns an XML document serializer with the specified options.
|
||||||
|
|
||||||
|
@param mask The XML document options.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
|
||||||
|
|
||||||
|
By default, `AFPropertyListResponseSerializer` accepts the following MIME types:
|
||||||
|
|
||||||
|
- `application/x-plist`
|
||||||
|
*/
|
||||||
|
@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
- (instancetype)init;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property list format. Possible values are described in "NSPropertyListFormat".
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSPropertyListFormat format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions."
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSPropertyListReadOptions readOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a property list serializer with a specified format, read options, and write options.
|
||||||
|
|
||||||
|
@param format The property list format.
|
||||||
|
@param readOptions The property list reading options.
|
||||||
|
*/
|
||||||
|
+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
|
||||||
|
readOptions:(NSPropertyListReadOptions)readOptions;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses.
|
||||||
|
|
||||||
|
By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
|
||||||
|
|
||||||
|
- `image/tiff`
|
||||||
|
- `image/jpeg`
|
||||||
|
- `image/gif`
|
||||||
|
- `image/png`
|
||||||
|
- `image/ico`
|
||||||
|
- `image/x-icon`
|
||||||
|
- `image/bmp`
|
||||||
|
- `image/x-bmp`
|
||||||
|
- `image/x-xbitmap`
|
||||||
|
- `image/x-win-bitmap`
|
||||||
|
*/
|
||||||
|
@interface AFImageResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||||
|
/**
|
||||||
|
The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) CGFloat imageScale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer.
|
||||||
|
*/
|
||||||
|
@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
/**
|
||||||
|
The component response serializers.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, copy) NSArray <id<AFURLResponseSerialization>> *responseSerializers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a compound serializer comprised of the specified response serializers.
|
||||||
|
|
||||||
|
@warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
|
||||||
|
*/
|
||||||
|
+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<AFURLResponseSerialization>> *)responseSerializers;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
///----------------
|
||||||
|
/// @name Constants
|
||||||
|
///----------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
## Error Domains
|
||||||
|
|
||||||
|
The following error domain is predefined.
|
||||||
|
|
||||||
|
- `NSString * const AFURLResponseSerializationErrorDomain`
|
||||||
|
|
||||||
|
### Constants
|
||||||
|
|
||||||
|
`AFURLResponseSerializationErrorDomain`
|
||||||
|
AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
## User info dictionary keys
|
||||||
|
|
||||||
|
These keys may exist in the user info dictionary, in addition to those defined for NSError.
|
||||||
|
|
||||||
|
- `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
|
||||||
|
- `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey`
|
||||||
|
|
||||||
|
### Constants
|
||||||
|
|
||||||
|
`AFNetworkingOperationFailingURLResponseErrorKey`
|
||||||
|
The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
|
||||||
|
|
||||||
|
`AFNetworkingOperationFailingURLResponseDataErrorKey`
|
||||||
|
The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
|
||||||
|
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFNetworkingOperationFailingURLResponseBodyErrorKey`
|
||||||
|
The corresponding value is an `NSString` containing the decoded error message.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseBodyErrorKey;
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,806 @@
|
|||||||
|
// AFURLResponseSerialization.m
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "AFURLResponseSerialization.h"
|
||||||
|
|
||||||
|
#import <TargetConditionals.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_WATCH
|
||||||
|
#import <WatchKit/WatchKit.h>
|
||||||
|
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
|
||||||
|
NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
|
||||||
|
NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
|
||||||
|
NSString * const AFNetworkingOperationFailingURLResponseBodyErrorKey = @"com.alamofire.serialization.response.error.body";
|
||||||
|
|
||||||
|
static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
|
||||||
|
if (!error) {
|
||||||
|
return underlyingError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
|
||||||
|
mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||||
|
|
||||||
|
return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
|
||||||
|
if ([error.domain isEqualToString:domain] && error.code == code) {
|
||||||
|
return YES;
|
||||||
|
} else if (error.userInfo[NSUnderlyingErrorKey]) {
|
||||||
|
return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
|
||||||
|
if ([JSONObject isKindOfClass:[NSArray class]]) {
|
||||||
|
NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]];
|
||||||
|
for (id value in (NSArray *)JSONObject) {
|
||||||
|
[mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray];
|
||||||
|
} else if ([JSONObject isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject];
|
||||||
|
for (id <NSCopying> key in [(NSDictionary *)JSONObject allKeys]) {
|
||||||
|
id value = (NSDictionary *)JSONObject[key];
|
||||||
|
if (!value || [value isEqual:[NSNull null]]) {
|
||||||
|
[mutableDictionary removeObjectForKey:key];
|
||||||
|
} else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
|
||||||
|
mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary];
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSONObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
return [[self alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.stringEncoding = NSUTF8StringEncoding;
|
||||||
|
|
||||||
|
self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
|
||||||
|
self.acceptableContentTypes = nil;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (BOOL)validateResponse:(NSHTTPURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
BOOL responseIsValid = YES;
|
||||||
|
NSError *validationError = nil;
|
||||||
|
|
||||||
|
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
|
if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
|
||||||
|
!([response MIMEType] == nil && [data length] == 0)) {
|
||||||
|
|
||||||
|
if ([data length] > 0 && [response URL]) {
|
||||||
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
|
||||||
|
NSURLErrorFailingURLErrorKey:[response URL],
|
||||||
|
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
|
} mutableCopy];
|
||||||
|
if (data) {
|
||||||
|
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
|
||||||
|
}
|
||||||
|
|
||||||
|
responseIsValid = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
||||||
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
||||||
|
NSURLErrorFailingURLErrorKey:[response URL],
|
||||||
|
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
|
} mutableCopy];
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
||||||
|
|
||||||
|
responseIsValid = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error && !responseIsValid) {
|
||||||
|
*error = validationError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseIsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
[self validateResponse:(NSHTTPURLResponse *)response data:data error:error];
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [self init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
|
||||||
|
self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
|
||||||
|
[coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
|
||||||
|
serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone];
|
||||||
|
serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone];
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation AFJSONResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
return [self serializerWithReadingOptions:(NSJSONReadingOptions)0];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions {
|
||||||
|
AFJSONResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
serializer.readingOptions = readingOptions;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id responseObject = nil;
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
// Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization.
|
||||||
|
// See https://github.com/rails/rails/issues/1742
|
||||||
|
BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]];
|
||||||
|
if (data.length > 0 && !isSpace) {
|
||||||
|
responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError];
|
||||||
|
} else {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.removesKeysWithNullValues && responseObject) {
|
||||||
|
responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
*error = AFErrorWithUnderlyingError(serializationError, *error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue];
|
||||||
|
self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[super encodeWithCoder:coder];
|
||||||
|
|
||||||
|
[coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))];
|
||||||
|
[coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
|
||||||
|
serializer.readingOptions = self.readingOptions;
|
||||||
|
serializer.removesKeysWithNullValues = self.removesKeysWithNullValues;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation AFXMLParserResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
AFXMLParserResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSHTTPURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [[NSXMLParser alloc] initWithData:data];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||||
|
|
||||||
|
@implementation AFXMLDocumentResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
return [self serializerWithXMLDocumentOptions:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask {
|
||||||
|
AFXMLDocumentResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
serializer.options = mask;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError];
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
*error = AFErrorWithUnderlyingError(serializationError, *error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[super encodeWithCoder:coder];
|
||||||
|
|
||||||
|
[coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
|
||||||
|
serializer.options = self.options;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation AFPropertyListResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
|
||||||
|
readOptions:(NSPropertyListReadOptions)readOptions
|
||||||
|
{
|
||||||
|
AFPropertyListResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
serializer.format = format;
|
||||||
|
serializer.readOptions = readOptions;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id responseObject;
|
||||||
|
NSError *serializationError = nil;
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
*error = AFErrorWithUnderlyingError(serializationError, *error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
|
||||||
|
self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[super encodeWithCoder:coder];
|
||||||
|
|
||||||
|
[coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
|
||||||
|
[coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
|
||||||
|
serializer.format = self.format;
|
||||||
|
serializer.readOptions = self.readOptions;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||||
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@interface UIImage (AFNetworkingSafeImageLoading)
|
||||||
|
+ (UIImage *)af_safeImageWithData:(NSData *)data;
|
||||||
|
@end
|
||||||
|
|
||||||
|
static NSLock* imageLock = nil;
|
||||||
|
|
||||||
|
@implementation UIImage (AFNetworkingSafeImageLoading)
|
||||||
|
|
||||||
|
+ (UIImage *)af_safeImageWithData:(NSData *)data {
|
||||||
|
UIImage* image = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
imageLock = [[NSLock alloc] init];
|
||||||
|
});
|
||||||
|
|
||||||
|
[imageLock lock];
|
||||||
|
image = [UIImage imageWithData:data];
|
||||||
|
[imageLock unlock];
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) {
|
||||||
|
UIImage *image = [UIImage af_safeImageWithData:data];
|
||||||
|
if (image.images) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation];
|
||||||
|
}
|
||||||
|
|
||||||
|
static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) {
|
||||||
|
if (!data || [data length] == 0) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGImageRef imageRef = NULL;
|
||||||
|
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
|
||||||
|
|
||||||
|
if ([response.MIMEType isEqualToString:@"image/png"]) {
|
||||||
|
imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
|
||||||
|
} else if ([response.MIMEType isEqualToString:@"image/jpeg"]) {
|
||||||
|
imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
|
||||||
|
|
||||||
|
if (imageRef) {
|
||||||
|
CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef);
|
||||||
|
CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace);
|
||||||
|
|
||||||
|
// CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale
|
||||||
|
if (imageColorSpaceModel == kCGColorSpaceModelCMYK) {
|
||||||
|
CGImageRelease(imageRef);
|
||||||
|
imageRef = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CGDataProviderRelease(dataProvider);
|
||||||
|
|
||||||
|
UIImage *image = AFImageWithDataAtScale(data, scale);
|
||||||
|
if (!imageRef) {
|
||||||
|
if (image.images || !image) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
imageRef = CGImageCreateCopy([image CGImage]);
|
||||||
|
if (!imageRef) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t width = CGImageGetWidth(imageRef);
|
||||||
|
size_t height = CGImageGetHeight(imageRef);
|
||||||
|
size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
|
||||||
|
|
||||||
|
if (width * height > 1024 * 1024 || bitsPerComponent > 8) {
|
||||||
|
CGImageRelease(imageRef);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate
|
||||||
|
size_t bytesPerRow = 0;
|
||||||
|
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||||
|
CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
|
||||||
|
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
|
||||||
|
|
||||||
|
if (colorSpaceModel == kCGColorSpaceModelRGB) {
|
||||||
|
uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask);
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wassign-enum"
|
||||||
|
if (alpha == kCGImageAlphaNone) {
|
||||||
|
bitmapInfo &= ~kCGBitmapAlphaInfoMask;
|
||||||
|
bitmapInfo |= kCGImageAlphaNoneSkipFirst;
|
||||||
|
} else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) {
|
||||||
|
bitmapInfo &= ~kCGBitmapAlphaInfoMask;
|
||||||
|
bitmapInfo |= kCGImageAlphaPremultipliedFirst;
|
||||||
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
|
CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
|
||||||
|
|
||||||
|
CGColorSpaceRelease(colorSpace);
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
CGImageRelease(imageRef);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef);
|
||||||
|
CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context);
|
||||||
|
|
||||||
|
CGContextRelease(context);
|
||||||
|
|
||||||
|
UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation];
|
||||||
|
|
||||||
|
CGImageRelease(inflatedImageRef);
|
||||||
|
CGImageRelease(imageRef);
|
||||||
|
|
||||||
|
return inflatedImage;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@implementation AFImageResponseSerializer
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil];
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||||
|
self.imageScale = [[UIScreen mainScreen] scale];
|
||||||
|
self.automaticallyInflatesResponseImage = YES;
|
||||||
|
#elif TARGET_OS_WATCH
|
||||||
|
self.imageScale = [[WKInterfaceDevice currentDevice] screenScale];
|
||||||
|
self.automaticallyInflatesResponseImage = YES;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerializer
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||||
|
if (self.automaticallyInflatesResponseImage) {
|
||||||
|
return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale);
|
||||||
|
} else {
|
||||||
|
return AFImageWithDataAtScale(data, self.imageScale);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Ensure that the image is set to it's correct pixel width and height
|
||||||
|
NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data];
|
||||||
|
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
|
||||||
|
[image addRepresentation:bitimage];
|
||||||
|
|
||||||
|
return image;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||||
|
NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))];
|
||||||
|
#if CGFLOAT_IS_DOUBLE
|
||||||
|
self.imageScale = [imageScale doubleValue];
|
||||||
|
#else
|
||||||
|
self.imageScale = [imageScale floatValue];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[super encodeWithCoder:coder];
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||||
|
[coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))];
|
||||||
|
[coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
|
||||||
|
serializer.imageScale = self.imageScale;
|
||||||
|
serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@interface AFCompoundResponseSerializer ()
|
||||||
|
@property (readwrite, nonatomic, copy) NSArray *responseSerializers;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AFCompoundResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers {
|
||||||
|
AFCompoundResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
serializer.responseSerializers = responseSerializers;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
|
||||||
|
if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *serializerError = nil;
|
||||||
|
id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError];
|
||||||
|
if (responseObject) {
|
||||||
|
if (error) {
|
||||||
|
*error = AFErrorWithUnderlyingError(serializerError, *error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [super responseObjectForResponse:response data:data error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||||
|
[super encodeWithCoder:coder];
|
||||||
|
|
||||||
|
[coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (instancetype)copyWithZone:(NSZone *)zone {
|
||||||
|
AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
|
||||||
|
serializer.responseSerializers = self.responseSerializers;
|
||||||
|
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,500 @@
|
|||||||
|
// AFURLSessionManager.h
|
||||||
|
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import "AFURLResponseSerialization.h"
|
||||||
|
#import "AFURLRequestSerialization.h"
|
||||||
|
#import "AFSecurityPolicy.h"
|
||||||
|
#if !TARGET_OS_WATCH
|
||||||
|
#import "AFNetworkReachabilityManager.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
|
||||||
|
|
||||||
|
## Subclassing Notes
|
||||||
|
|
||||||
|
This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead.
|
||||||
|
|
||||||
|
## NSURLSession & NSURLSessionTask Delegate Methods
|
||||||
|
|
||||||
|
`AFURLSessionManager` implements the following delegate methods:
|
||||||
|
|
||||||
|
### `NSURLSessionDelegate`
|
||||||
|
|
||||||
|
- `URLSession:didBecomeInvalidWithError:`
|
||||||
|
- `URLSession:didReceiveChallenge:completionHandler:`
|
||||||
|
- `URLSessionDidFinishEventsForBackgroundURLSession:`
|
||||||
|
|
||||||
|
### `NSURLSessionTaskDelegate`
|
||||||
|
|
||||||
|
- `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`
|
||||||
|
- `URLSession:task:didReceiveChallenge:completionHandler:`
|
||||||
|
- `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`
|
||||||
|
- `URLSession:task:needNewBodyStream:`
|
||||||
|
- `URLSession:task:didCompleteWithError:`
|
||||||
|
|
||||||
|
### `NSURLSessionDataDelegate`
|
||||||
|
|
||||||
|
- `URLSession:dataTask:didReceiveResponse:completionHandler:`
|
||||||
|
- `URLSession:dataTask:didBecomeDownloadTask:`
|
||||||
|
- `URLSession:dataTask:didReceiveData:`
|
||||||
|
- `URLSession:dataTask:willCacheResponse:completionHandler:`
|
||||||
|
|
||||||
|
### `NSURLSessionDownloadDelegate`
|
||||||
|
|
||||||
|
- `URLSession:downloadTask:didFinishDownloadingToURL:`
|
||||||
|
- `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`
|
||||||
|
- `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`
|
||||||
|
|
||||||
|
If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
|
||||||
|
|
||||||
|
## Network Reachability Monitoring
|
||||||
|
|
||||||
|
Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details.
|
||||||
|
|
||||||
|
## NSCoding Caveats
|
||||||
|
|
||||||
|
- Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`.
|
||||||
|
|
||||||
|
## NSCopying Caveats
|
||||||
|
|
||||||
|
- `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original.
|
||||||
|
- Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied.
|
||||||
|
|
||||||
|
@warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The managed session.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSURLSession *session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The operation queue on which delegate callbacks are run.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
|
||||||
|
|
||||||
|
@warning `responseSerializer` must not be `nil`.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
|
||||||
|
|
||||||
|
///-------------------------------
|
||||||
|
/// @name Managing Security Policy
|
||||||
|
///-------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
|
||||||
|
|
||||||
|
#if !TARGET_OS_WATCH
|
||||||
|
///--------------------------------------
|
||||||
|
/// @name Monitoring Network Reachability
|
||||||
|
///--------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default.
|
||||||
|
*/
|
||||||
|
@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///----------------------------
|
||||||
|
/// @name Getting Session Tasks
|
||||||
|
///----------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
The data, upload, and download tasks currently run by the managed session.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSArray <NSURLSessionTask *> *tasks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The data tasks currently run by the managed session.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSArray <NSURLSessionDataTask *> *dataTasks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The upload tasks currently run by the managed session.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSArray <NSURLSessionUploadTask *> *uploadTasks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The download tasks currently run by the managed session.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic, strong) NSArray <NSURLSessionDownloadTask *> *downloadTasks;
|
||||||
|
|
||||||
|
///-------------------------------
|
||||||
|
/// @name Managing Callback Queues
|
||||||
|
///-------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong, nullable) dispatch_group_t completionGroup;
|
||||||
|
|
||||||
|
///---------------------------------
|
||||||
|
/// @name Working Around System Bugs
|
||||||
|
///---------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default.
|
||||||
|
|
||||||
|
@bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again.
|
||||||
|
|
||||||
|
@see https://github.com/AFNetworking/AFNetworking/issues/1675
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions;
|
||||||
|
|
||||||
|
///---------------------
|
||||||
|
/// @name Initialization
|
||||||
|
///---------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and returns a manager for a session created with the specified configuration. This is the designated initializer.
|
||||||
|
|
||||||
|
@param configuration The configuration used to create the managed session.
|
||||||
|
|
||||||
|
@return A manager for a newly-created session.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Invalidates the managed session, optionally canceling pending tasks.
|
||||||
|
|
||||||
|
@param cancelPendingTasks Whether or not to cancel pending tasks.
|
||||||
|
*/
|
||||||
|
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks;
|
||||||
|
|
||||||
|
///-------------------------
|
||||||
|
/// @name Running Data Tasks
|
||||||
|
///-------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionDataTask` with the specified request.
|
||||||
|
|
||||||
|
@param request The HTTP request for the request.
|
||||||
|
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||||
|
*/
|
||||||
|
- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionDataTask` with the specified request.
|
||||||
|
|
||||||
|
@param request The HTTP request for the request.
|
||||||
|
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||||
|
*/
|
||||||
|
- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
|
||||||
|
uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||||
|
downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
///---------------------------
|
||||||
|
/// @name Running Upload Tasks
|
||||||
|
///---------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionUploadTask` with the specified request for a local file.
|
||||||
|
|
||||||
|
@param request The HTTP request for the request.
|
||||||
|
@param fileURL A URL to the local file to be uploaded.
|
||||||
|
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||||
|
|
||||||
|
@see `attemptsToRecreateUploadTasksForBackgroundSessions`
|
||||||
|
*/
|
||||||
|
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
|
||||||
|
fromFile:(NSURL *)fileURL
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body.
|
||||||
|
|
||||||
|
@param request The HTTP request for the request.
|
||||||
|
@param bodyData A data object containing the HTTP body to be uploaded.
|
||||||
|
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||||
|
*/
|
||||||
|
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
|
||||||
|
fromData:(nullable NSData *)bodyData
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionUploadTask` with the specified streaming request.
|
||||||
|
|
||||||
|
@param request The HTTP request for the request.
|
||||||
|
@param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
|
||||||
|
*/
|
||||||
|
- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
|
||||||
|
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
///-----------------------------
|
||||||
|
/// @name Running Download Tasks
|
||||||
|
///-----------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionDownloadTask` with the specified request.
|
||||||
|
|
||||||
|
@param request The HTTP request for the request.
|
||||||
|
@param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
|
||||||
|
@param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
|
||||||
|
|
||||||
|
@warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method.
|
||||||
|
*/
|
||||||
|
- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
|
||||||
|
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
|
||||||
|
destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an `NSURLSessionDownloadTask` with the specified resume data.
|
||||||
|
|
||||||
|
@param resumeData The data used to resume downloading.
|
||||||
|
@param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||||
|
@param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
|
||||||
|
@param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
|
||||||
|
*/
|
||||||
|
- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
|
||||||
|
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
|
||||||
|
destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
|
||||||
|
completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
|
||||||
|
|
||||||
|
///---------------------------------
|
||||||
|
/// @name Getting Progress for Tasks
|
||||||
|
///---------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the upload progress of the specified task.
|
||||||
|
|
||||||
|
@param task The session task. Must not be `nil`.
|
||||||
|
|
||||||
|
@return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable.
|
||||||
|
*/
|
||||||
|
- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the download progress of the specified task.
|
||||||
|
|
||||||
|
@param task The session task. Must not be `nil`.
|
||||||
|
|
||||||
|
@return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable.
|
||||||
|
*/
|
||||||
|
- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task;
|
||||||
|
|
||||||
|
///-----------------------------------------
|
||||||
|
/// @name Setting Session Delegate Callbacks
|
||||||
|
///-----------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation.
|
||||||
|
*/
|
||||||
|
- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge.
|
||||||
|
*/
|
||||||
|
- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
|
||||||
|
|
||||||
|
///--------------------------------------
|
||||||
|
/// @name Setting Task Delegate Callbacks
|
||||||
|
///--------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a task requires a new request body stream.
|
||||||
|
*/
|
||||||
|
- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response.
|
||||||
|
*/
|
||||||
|
- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge.
|
||||||
|
*/
|
||||||
|
- (void)setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`.
|
||||||
|
|
||||||
|
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
|
||||||
|
*/
|
||||||
|
- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task.
|
||||||
|
*/
|
||||||
|
- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block;
|
||||||
|
|
||||||
|
///-------------------------------------------
|
||||||
|
/// @name Setting Data Task Delegate Callbacks
|
||||||
|
///-------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response.
|
||||||
|
*/
|
||||||
|
- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become.
|
||||||
|
*/
|
||||||
|
- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`.
|
||||||
|
|
||||||
|
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue.
|
||||||
|
*/
|
||||||
|
- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response.
|
||||||
|
*/
|
||||||
|
- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session.
|
||||||
|
*/
|
||||||
|
- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block;
|
||||||
|
|
||||||
|
///-----------------------------------------------
|
||||||
|
/// @name Setting Download Task Delegate Callbacks
|
||||||
|
///-----------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error.
|
||||||
|
*/
|
||||||
|
- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`.
|
||||||
|
|
||||||
|
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue.
|
||||||
|
*/
|
||||||
|
- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`.
|
||||||
|
|
||||||
|
@param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded.
|
||||||
|
*/
|
||||||
|
- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
///--------------------
|
||||||
|
/// @name Notifications
|
||||||
|
///--------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posted when a task resumes.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posted when a task suspends its execution.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posted when a session is invalidated.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posted when a session download task encountered an error when moving the temporary download file to a specified destination.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey;
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,8 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AFURLRequestSerialization.h"
|
||||||
|
|
||||||
|
@interface BinaryRequestSerializer : AFHTTPRequestSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,53 @@
|
|||||||
|
#import "BinaryRequestSerializer.h"
|
||||||
|
|
||||||
|
@implementation BinaryRequestSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer
|
||||||
|
{
|
||||||
|
BinaryRequestSerializer *serializer = [[self alloc] init];
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLRequestSerialization
|
||||||
|
|
||||||
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
|
withParameters:(id)parameters
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
NSParameterAssert(request);
|
||||||
|
|
||||||
|
if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
|
||||||
|
return [super requestBySerializingRequest:request withParameters:parameters error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableURLRequest *mutableRequest = [request mutableCopy];
|
||||||
|
|
||||||
|
[self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
|
||||||
|
if (![request valueForHTTPHeaderField:field]) {
|
||||||
|
[mutableRequest setValue:value forHTTPHeaderField:field];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
if (parameters) {
|
||||||
|
if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
|
||||||
|
[mutableRequest setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];
|
||||||
|
}
|
||||||
|
|
||||||
|
[mutableRequest setHTTPBody: parameters];
|
||||||
|
}
|
||||||
|
|
||||||
|
return mutableRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,8 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AFURLResponseSerialization.h"
|
||||||
|
|
||||||
|
@interface BinaryResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,126 @@
|
|||||||
|
#import "BinaryResponseSerializer.h"
|
||||||
|
|
||||||
|
static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
|
||||||
|
if (!error) {
|
||||||
|
return underlyingError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
|
||||||
|
mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||||
|
|
||||||
|
return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
|
||||||
|
if ([error.domain isEqualToString:domain] && error.code == code) {
|
||||||
|
return YES;
|
||||||
|
} else if (error.userInfo[NSUnderlyingErrorKey]) {
|
||||||
|
return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation BinaryResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
BinaryResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = nil;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)decodeResponseData:(NSData*)rawResponseData withEncoding:(CFStringEncoding)cfEncoding {
|
||||||
|
NSStringEncoding nsEncoding;
|
||||||
|
NSString* decoded = nil;
|
||||||
|
|
||||||
|
if (cfEncoding != kCFStringEncodingInvalidId) {
|
||||||
|
nsEncoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSStringEncoding supportedEncodings[6] = {
|
||||||
|
NSUTF8StringEncoding, NSWindowsCP1252StringEncoding, NSISOLatin1StringEncoding,
|
||||||
|
NSISOLatin2StringEncoding, NSASCIIStringEncoding, NSUnicodeStringEncoding
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(supportedEncodings) / sizeof(NSStringEncoding) && !decoded; ++i) {
|
||||||
|
if (cfEncoding == kCFStringEncodingInvalidId || nsEncoding == supportedEncodings[i]) {
|
||||||
|
decoded = [[NSString alloc] initWithData:rawResponseData encoding:supportedEncodings[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CFStringEncoding) getEncoding:(NSURLResponse *)response {
|
||||||
|
CFStringEncoding encoding = kCFStringEncodingInvalidId;
|
||||||
|
|
||||||
|
if (response.textEncodingName) {
|
||||||
|
encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (BOOL)validateResponse:(NSHTTPURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
|
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
||||||
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
||||||
|
NSURLErrorFailingURLErrorKey: [response URL],
|
||||||
|
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
|
} mutableCopy];
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
|
|
||||||
|
// trying to decode error message in body
|
||||||
|
mutableUserInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey] = [self decodeResponseData:data withEncoding:[self getEncoding:response]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
*error = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [data base64EncodedStringWithOptions:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,19 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
@interface CordovaHttpPlugin : CDVPlugin
|
||||||
|
|
||||||
|
- (void)setServerTrustMode:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)setClientAuthMode:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)post:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)put:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)patch:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)get:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)delete:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)head:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)options:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)uploadFiles:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)downloadFile:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,565 @@
|
|||||||
|
#import "CordovaHttpPlugin.h"
|
||||||
|
#import "CDVFile.h"
|
||||||
|
#import "BinaryRequestSerializer.h"
|
||||||
|
#import "BinaryResponseSerializer.h"
|
||||||
|
#import "TextResponseSerializer.h"
|
||||||
|
#import "TextRequestSerializer.h"
|
||||||
|
#import "AFHTTPSessionManager.h"
|
||||||
|
#import "SDNetworkActivityIndicator.h"
|
||||||
|
|
||||||
|
@interface CordovaHttpPlugin()
|
||||||
|
|
||||||
|
- (void)setRequestHeaders:(NSDictionary*)headers forManager:(AFHTTPSessionManager*)manager;
|
||||||
|
- (void)handleSuccess:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response andData:(id)data;
|
||||||
|
- (void)handleError:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response error:(NSError*)error;
|
||||||
|
- (NSNumber*)getStatusCode:(NSError*) error;
|
||||||
|
- (NSMutableDictionary*)copyHeaderFields:(NSDictionary*)headerFields;
|
||||||
|
- (void)setTimeout:(NSTimeInterval)timeout forManager:(AFHTTPSessionManager*)manager;
|
||||||
|
- (void)setRedirect:(bool)redirect forManager:(AFHTTPSessionManager*)manager;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation CordovaHttpPlugin {
|
||||||
|
AFSecurityPolicy *securityPolicy;
|
||||||
|
NSURLCredential *x509Credential;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)pluginInitialize {
|
||||||
|
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setRequestSerializer:(NSString*)serializerName forManager:(AFHTTPSessionManager*)manager {
|
||||||
|
if ([serializerName isEqualToString:@"json"]) {
|
||||||
|
manager.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||||
|
} else if ([serializerName isEqualToString:@"utf8"]) {
|
||||||
|
manager.requestSerializer = [TextRequestSerializer serializer];
|
||||||
|
} else if ([serializerName isEqualToString:@"raw"]) {
|
||||||
|
manager.requestSerializer = [BinaryRequestSerializer serializer];
|
||||||
|
} else {
|
||||||
|
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setupAuthChallengeBlock:(AFHTTPSessionManager*)manager {
|
||||||
|
[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(
|
||||||
|
NSURLSession * _Nonnull session,
|
||||||
|
NSURLAuthenticationChallenge * _Nonnull challenge,
|
||||||
|
NSURLCredential * _Nullable __autoreleasing * _Nullable credential
|
||||||
|
) {
|
||||||
|
if ([challenge.protectionSpace.authenticationMethod isEqualToString: NSURLAuthenticationMethodServerTrust]) {
|
||||||
|
*credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
||||||
|
|
||||||
|
if (![self->securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) {
|
||||||
|
return NSURLSessionAuthChallengeRejectProtectionSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (credential) {
|
||||||
|
return NSURLSessionAuthChallengeUseCredential;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([challenge.protectionSpace.authenticationMethod isEqualToString: NSURLAuthenticationMethodClientCertificate] && self->x509Credential) {
|
||||||
|
*credential = self->x509Credential;
|
||||||
|
return NSURLSessionAuthChallengeUseCredential;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NSURLSessionAuthChallengePerformDefaultHandling;
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setRequestHeaders:(NSDictionary*)headers forManager:(AFHTTPSessionManager*)manager {
|
||||||
|
[headers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
[manager.requestSerializer setValue:obj forHTTPHeaderField:key];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setRedirect:(bool)followRedirect forManager:(AFHTTPSessionManager*)manager {
|
||||||
|
[manager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest * _Nonnull(NSURLSession * _Nonnull session,
|
||||||
|
NSURLSessionTask * _Nonnull task, NSURLResponse * _Nonnull response, NSURLRequest * _Nonnull request) {
|
||||||
|
|
||||||
|
if (followRedirect) {
|
||||||
|
return request;
|
||||||
|
} else {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTimeout:(NSTimeInterval)timeout forManager:(AFHTTPSessionManager*)manager {
|
||||||
|
[manager.requestSerializer setTimeoutInterval:timeout];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setResponseSerializer:(NSString*)responseType forManager:(AFHTTPSessionManager*)manager {
|
||||||
|
if ([responseType isEqualToString: @"text"] || [responseType isEqualToString: @"json"]) {
|
||||||
|
manager.responseSerializer = [TextResponseSerializer serializer];
|
||||||
|
} else {
|
||||||
|
manager.responseSerializer = [BinaryResponseSerializer serializer];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)handleSuccess:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response andData:(id)data {
|
||||||
|
if (response != nil) {
|
||||||
|
[dictionary setValue:response.URL.absoluteString forKey:@"url"];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:(int)response.statusCode] forKey:@"status"];
|
||||||
|
[dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data != nil) {
|
||||||
|
[dictionary setObject:data forKey:@"data"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)handleError:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResponse*)response error:(NSError*)error {
|
||||||
|
if (response != nil) {
|
||||||
|
[dictionary setValue:response.URL.absoluteString forKey:@"url"];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:(int)response.statusCode] forKey:@"status"];
|
||||||
|
[dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"];
|
||||||
|
if (error.userInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey]) {
|
||||||
|
[dictionary setObject:error.userInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey] forKey:@"error"];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
[dictionary setObject:[self getStatusCode:error] forKey:@"status"];
|
||||||
|
[dictionary setObject:[error localizedDescription] forKey:@"error"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)handleException:(NSException*)exception withCommand:(CDVInvokedUrlCommand*)command {
|
||||||
|
CordovaHttpPlugin* __weak weakSelf = self;
|
||||||
|
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[dictionary setValue:exception.userInfo forKey:@"error"];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:-1] forKey:@"status"];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSNumber*)getStatusCode:(NSError*) error {
|
||||||
|
switch ([error code]) {
|
||||||
|
case -1001:
|
||||||
|
// timeout
|
||||||
|
return [NSNumber numberWithInt:-4];
|
||||||
|
case -1002:
|
||||||
|
// unsupported URL
|
||||||
|
return [NSNumber numberWithInt:-5];
|
||||||
|
case -1003:
|
||||||
|
// server not found
|
||||||
|
return [NSNumber numberWithInt:-3];
|
||||||
|
case -1009:
|
||||||
|
// no connection
|
||||||
|
return [NSNumber numberWithInt:-6];
|
||||||
|
case -1200: // secure connection failed
|
||||||
|
case -1201: // certificate has bad date
|
||||||
|
case -1202: // certificate untrusted
|
||||||
|
case -1203: // certificate has unknown root
|
||||||
|
case -1204: // certificate is not yet valid
|
||||||
|
// configuring SSL failed
|
||||||
|
return [NSNumber numberWithInt:-2];
|
||||||
|
default:
|
||||||
|
return [NSNumber numberWithInt:-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableDictionary*)copyHeaderFields:(NSDictionary *)headerFields {
|
||||||
|
NSMutableDictionary *headerFieldsCopy = [[NSMutableDictionary alloc] initWithCapacity:headerFields.count];
|
||||||
|
NSString *headerKeyCopy;
|
||||||
|
|
||||||
|
for (NSString *headerKey in headerFields.allKeys) {
|
||||||
|
headerKeyCopy = [[headerKey mutableCopy] lowercaseString];
|
||||||
|
[headerFieldsCopy setValue:[headerFields objectForKey:headerKey] forKey:headerKeyCopy];
|
||||||
|
}
|
||||||
|
|
||||||
|
return headerFieldsCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)executeRequestWithoutData:(CDVInvokedUrlCommand*)command withMethod:(NSString*) method {
|
||||||
|
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||||
|
|
||||||
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
|
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
||||||
|
NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:2] doubleValue];
|
||||||
|
bool followRedirect = [[command.arguments objectAtIndex:3] boolValue];
|
||||||
|
NSString *responseType = [command.arguments objectAtIndex:4];
|
||||||
|
|
||||||
|
[self setRequestSerializer: @"default" forManager: manager];
|
||||||
|
[self setupAuthChallengeBlock: manager];
|
||||||
|
[self setRequestHeaders: headers forManager: manager];
|
||||||
|
[self setTimeout:timeoutInSeconds forManager:manager];
|
||||||
|
[self setRedirect:followRedirect forManager:manager];
|
||||||
|
[self setResponseSerializer:responseType forManager:manager];
|
||||||
|
|
||||||
|
CordovaHttpPlugin* __weak weakSelf = self;
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] startActivity];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
void (^onSuccess)(NSURLSessionTask *, id) = ^(NSURLSessionTask *task, id responseObject) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
|
// no 'body' for HEAD request, omitting 'data'
|
||||||
|
if ([method isEqualToString:@"HEAD"]) {
|
||||||
|
[self handleSuccess:dictionary withResponse:(NSHTTPURLResponse*)task.response andData:nil];
|
||||||
|
} else {
|
||||||
|
[self handleSuccess:dictionary withResponse:(NSHTTPURLResponse*)task.response andData:responseObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
};
|
||||||
|
|
||||||
|
void (^onFailure)(NSURLSessionTask *, NSError *) = ^(NSURLSessionTask *task, NSError *error) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleError:dictionary withResponse:(NSHTTPURLResponse*)task.response error:error];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
};
|
||||||
|
|
||||||
|
[manager downloadTaskWithHTTPMethod:method URLString:url parameters:nil progress:nil success:onSuccess failure:onFailure];
|
||||||
|
}
|
||||||
|
@catch (NSException *exception) {
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
[self handleException:exception withCommand:command];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)executeRequestWithData:(CDVInvokedUrlCommand*)command withMethod:(NSString*)method {
|
||||||
|
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||||
|
|
||||||
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
|
NSDictionary *data = [command.arguments objectAtIndex:1];
|
||||||
|
NSString *serializerName = [command.arguments objectAtIndex:2];
|
||||||
|
NSDictionary *headers = [command.arguments objectAtIndex:3];
|
||||||
|
NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:4] doubleValue];
|
||||||
|
bool followRedirect = [[command.arguments objectAtIndex:5] boolValue];
|
||||||
|
NSString *responseType = [command.arguments objectAtIndex:6];
|
||||||
|
|
||||||
|
[self setRequestSerializer: serializerName forManager: manager];
|
||||||
|
[self setupAuthChallengeBlock: manager];
|
||||||
|
[self setRequestHeaders: headers forManager: manager];
|
||||||
|
[self setTimeout:timeoutInSeconds forManager:manager];
|
||||||
|
[self setRedirect:followRedirect forManager:manager];
|
||||||
|
[self setResponseSerializer:responseType forManager:manager];
|
||||||
|
|
||||||
|
CordovaHttpPlugin* __weak weakSelf = self;
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] startActivity];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
void (^constructBody)(id<AFMultipartFormData>) = ^(id<AFMultipartFormData> formData) {
|
||||||
|
NSArray *buffers = [data mutableArrayValueForKey:@"buffers"];
|
||||||
|
NSArray *fileNames = [data mutableArrayValueForKey:@"fileNames"];
|
||||||
|
NSArray *names = [data mutableArrayValueForKey:@"names"];
|
||||||
|
NSArray *types = [data mutableArrayValueForKey:@"types"];
|
||||||
|
|
||||||
|
NSError *error;
|
||||||
|
|
||||||
|
for (int i = 0; i < [buffers count]; ++i) {
|
||||||
|
NSData *decodedBuffer = [[NSData alloc] initWithBase64EncodedString:[buffers objectAtIndex:i] options:0];
|
||||||
|
NSString *fileName = [fileNames objectAtIndex:i];
|
||||||
|
NSString *partName = [names objectAtIndex:i];
|
||||||
|
NSString *partType = [types objectAtIndex:i];
|
||||||
|
|
||||||
|
if (![fileName isEqual:[NSNull null]]) {
|
||||||
|
[formData appendPartWithFileData:decodedBuffer name:partName fileName:fileName mimeType:partType];
|
||||||
|
} else {
|
||||||
|
[formData appendPartWithFormData:decodedBuffer name:[names objectAtIndex:i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:400] forKey:@"status"];
|
||||||
|
[dictionary setObject:@"Could not add part to multipart request body." forKey:@"error"];
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void (^onSuccess)(NSURLSessionTask *, id) = ^(NSURLSessionTask *task, id responseObject) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleSuccess:dictionary withResponse:(NSHTTPURLResponse*)task.response andData:responseObject];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
};
|
||||||
|
|
||||||
|
void (^onFailure)(NSURLSessionTask *, NSError *) = ^(NSURLSessionTask *task, NSError *error) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleError:dictionary withResponse:(NSHTTPURLResponse*)task.response error:error];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
};
|
||||||
|
|
||||||
|
if ([serializerName isEqualToString:@"multipart"]) {
|
||||||
|
[manager uploadTaskWithHTTPMethod:method URLString:url parameters:nil constructingBodyWithBlock:constructBody progress:nil success:onSuccess failure:onFailure];
|
||||||
|
} else {
|
||||||
|
[manager uploadTaskWithHTTPMethod:method URLString:url parameters:data progress:nil success:onSuccess failure:onFailure];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@catch (NSException *exception) {
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
[self handleException:exception withCommand:command];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setServerTrustMode:(CDVInvokedUrlCommand*)command {
|
||||||
|
NSString *certMode = [command.arguments objectAtIndex:0];
|
||||||
|
|
||||||
|
if ([certMode isEqualToString: @"default"] || [certMode isEqualToString: @"legacy"]) {
|
||||||
|
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
|
securityPolicy.allowInvalidCertificates = NO;
|
||||||
|
securityPolicy.validatesDomainName = YES;
|
||||||
|
} else if ([certMode isEqualToString: @"nocheck"]) {
|
||||||
|
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
|
||||||
|
securityPolicy.allowInvalidCertificates = YES;
|
||||||
|
securityPolicy.validatesDomainName = NO;
|
||||||
|
} else if ([certMode isEqualToString: @"pinned"]) {
|
||||||
|
securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
||||||
|
securityPolicy.allowInvalidCertificates = NO;
|
||||||
|
securityPolicy.validatesDomainName = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setClientAuthMode:(CDVInvokedUrlCommand*)command {
|
||||||
|
CDVPluginResult* pluginResult;
|
||||||
|
NSString *mode = [command.arguments objectAtIndex:0];
|
||||||
|
|
||||||
|
if ([mode isEqualToString:@"none"]) {
|
||||||
|
x509Credential = nil;
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([mode isEqualToString:@"systemstore"]) {
|
||||||
|
NSString *alias = [command.arguments objectAtIndex:1];
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"mode 'systemstore' is not supported on iOS"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([mode isEqualToString:@"buffer"]) {
|
||||||
|
CFDataRef container = (__bridge CFDataRef) [command.arguments objectAtIndex:2];
|
||||||
|
CFStringRef password = (__bridge CFStringRef) [command.arguments objectAtIndex:3];
|
||||||
|
|
||||||
|
const void *keys[] = { kSecImportExportPassphrase };
|
||||||
|
const void *values[] = { password };
|
||||||
|
|
||||||
|
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL);
|
||||||
|
CFArrayRef items;
|
||||||
|
OSStatus securityError = SecPKCS12Import(container, options, &items);
|
||||||
|
CFRelease(options);
|
||||||
|
|
||||||
|
if (securityError != noErr) {
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
||||||
|
} else {
|
||||||
|
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
|
||||||
|
SecIdentityRef identity = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity);
|
||||||
|
|
||||||
|
self->x509Credential = [NSURLCredential credentialWithIdentity:identity certificates: nil persistence:NSURLCredentialPersistenceForSession];
|
||||||
|
CFRelease(items);
|
||||||
|
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)post:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithData: command withMethod:@"POST"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)put:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithData: command withMethod:@"PUT"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)patch:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithData: command withMethod:@"PATCH"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)get:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithoutData: command withMethod:@"GET"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)delete:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithoutData: command withMethod:@"DELETE"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)head:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithoutData: command withMethod:@"HEAD"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)options:(CDVInvokedUrlCommand*)command {
|
||||||
|
[self executeRequestWithoutData: command withMethod:@"OPTIONS"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)uploadFiles:(CDVInvokedUrlCommand*)command {
|
||||||
|
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||||
|
|
||||||
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
|
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
||||||
|
NSArray *filePaths = [command.arguments objectAtIndex: 2];
|
||||||
|
NSArray *names = [command.arguments objectAtIndex: 3];
|
||||||
|
NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:4] doubleValue];
|
||||||
|
bool followRedirect = [[command.arguments objectAtIndex:5] boolValue];
|
||||||
|
NSString *responseType = [command.arguments objectAtIndex:6];
|
||||||
|
|
||||||
|
[self setRequestHeaders: headers forManager: manager];
|
||||||
|
[self setupAuthChallengeBlock: manager];
|
||||||
|
[self setTimeout:timeoutInSeconds forManager:manager];
|
||||||
|
[self setRedirect:followRedirect forManager:manager];
|
||||||
|
[self setResponseSerializer:responseType forManager:manager];
|
||||||
|
|
||||||
|
CordovaHttpPlugin* __weak weakSelf = self;
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] startActivity];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
[manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||||
|
NSError *error;
|
||||||
|
for (int i = 0; i < [filePaths count]; i++) {
|
||||||
|
NSString *filePath = (NSString *) [filePaths objectAtIndex:i];
|
||||||
|
NSString *uploadName = (NSString *) [names objectAtIndex:i];
|
||||||
|
NSURL *fileURL = [NSURL URLWithString: filePath];
|
||||||
|
[formData appendPartWithFileURL:fileURL name:uploadName error:&error];
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:500] forKey:@"status"];
|
||||||
|
[dictionary setObject:@"Could not add file to post body." forKey:@"error"];
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} progress:nil success:^(NSURLSessionTask *task, id responseObject) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleSuccess:dictionary withResponse:(NSHTTPURLResponse*)task.response andData:responseObject];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
} failure:^(NSURLSessionTask *task, NSError *error) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleError:dictionary withResponse:(NSHTTPURLResponse*)task.response error:error];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
@catch (NSException *exception) {
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
[self handleException:exception withCommand:command];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloadFile:(CDVInvokedUrlCommand*)command {
|
||||||
|
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||||
|
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
|
||||||
|
|
||||||
|
NSString *url = [command.arguments objectAtIndex:0];
|
||||||
|
NSDictionary *headers = [command.arguments objectAtIndex:1];
|
||||||
|
NSString *filePath = [command.arguments objectAtIndex: 2];
|
||||||
|
NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:3] doubleValue];
|
||||||
|
bool followRedirect = [[command.arguments objectAtIndex:4] boolValue];
|
||||||
|
|
||||||
|
[self setRequestHeaders: headers forManager: manager];
|
||||||
|
[self setupAuthChallengeBlock: manager];
|
||||||
|
[self setTimeout:timeoutInSeconds forManager:manager];
|
||||||
|
[self setRedirect:followRedirect forManager:manager];
|
||||||
|
|
||||||
|
if ([filePath hasPrefix:@"file://"]) {
|
||||||
|
filePath = [filePath substringFromIndex:7];
|
||||||
|
}
|
||||||
|
|
||||||
|
CordovaHttpPlugin* __weak weakSelf = self;
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] startActivity];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
[manager GET:url parameters:nil progress: nil success:^(NSURLSessionTask *task, id responseObject) {
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Modified by Andrew Stephan for Sync OnSet
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// Download response is okay; begin streaming output to file
|
||||||
|
NSString* parentPath = [filePath stringByDeletingLastPathComponent];
|
||||||
|
|
||||||
|
// create parent directories if needed
|
||||||
|
NSError *error;
|
||||||
|
if ([[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:&error] == NO) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:500] forKey:@"status"];
|
||||||
|
if (error) {
|
||||||
|
[dictionary setObject:[NSString stringWithFormat:@"Could not create path to save downloaded file: %@", [error localizedDescription]] forKey:@"error"];
|
||||||
|
} else {
|
||||||
|
[dictionary setObject:@"Could not create path to save downloaded file" forKey:@"error"];
|
||||||
|
}
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSData *data = (NSData *)responseObject;
|
||||||
|
if (![data writeToFile:filePath atomically:YES]) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[dictionary setObject:[NSNumber numberWithInt:500] forKey:@"status"];
|
||||||
|
[dictionary setObject:@"Could not write the data to the given filePath." forKey:@"error"];
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
id filePlugin = [self.commandDelegate getCommandInstance:@"File"];
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleSuccess:dictionary withResponse:(NSHTTPURLResponse*)task.response andData:nil];
|
||||||
|
[dictionary setObject:[filePlugin getDirectoryEntry:filePath isDirectory:NO] forKey:@"file"];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
} failure:^(NSURLSessionTask *task, NSError *error) {
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
[self handleError:dictionary withResponse:(NSHTTPURLResponse*)task.response error:error];
|
||||||
|
[dictionary setObject:@"There was an error downloading the file" forKey:@"error"];
|
||||||
|
|
||||||
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
|
||||||
|
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
@catch (NSException *exception) {
|
||||||
|
[[SDNetworkActivityIndicator sharedActivityIndicator] stopActivity];
|
||||||
|
[self handleException:exception withCommand:command];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the SDNetworkActivityIndicator package.
|
||||||
|
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface SDNetworkActivityIndicator : NSObject
|
||||||
|
|
||||||
|
+ (id)sharedActivityIndicator;
|
||||||
|
- (void)startActivity;
|
||||||
|
- (void)stopActivity;
|
||||||
|
- (void)stopAllActivity;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the SDNetworkActivityIndicator package.
|
||||||
|
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "SDNetworkActivityIndicator.h"
|
||||||
|
|
||||||
|
@interface SDNetworkActivityIndicator()
|
||||||
|
{
|
||||||
|
@private NSUInteger counter;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation SDNetworkActivityIndicator
|
||||||
|
|
||||||
|
+ (instancetype) sharedActivityIndicator
|
||||||
|
{
|
||||||
|
static id _sharedInstance = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
_sharedInstance = [[self alloc] init];
|
||||||
|
});
|
||||||
|
|
||||||
|
return _sharedInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
if ((self = [super init]))
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startActivity
|
||||||
|
{
|
||||||
|
@synchronized(self)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)stopActivity
|
||||||
|
{
|
||||||
|
@synchronized(self)
|
||||||
|
{
|
||||||
|
if (counter > 0 && --counter == 0)
|
||||||
|
{
|
||||||
|
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)stopAllActivity
|
||||||
|
{
|
||||||
|
@synchronized(self)
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,8 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AFURLRequestSerialization.h"
|
||||||
|
|
||||||
|
@interface TextRequestSerializer : AFHTTPRequestSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,53 @@
|
|||||||
|
#import "TextRequestSerializer.h"
|
||||||
|
|
||||||
|
@implementation TextRequestSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer
|
||||||
|
{
|
||||||
|
TextRequestSerializer *serializer = [[self alloc] init];
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLRequestSerialization
|
||||||
|
|
||||||
|
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||||
|
withParameters:(id)parameters
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
NSParameterAssert(request);
|
||||||
|
|
||||||
|
if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
|
||||||
|
return [super requestBySerializingRequest:request withParameters:parameters error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableURLRequest *mutableRequest = [request mutableCopy];
|
||||||
|
|
||||||
|
[self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
|
||||||
|
if (![request valueForHTTPHeaderField:field]) {
|
||||||
|
[mutableRequest setValue:value forHTTPHeaderField:field];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
if (parameters) {
|
||||||
|
if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
|
||||||
|
[mutableRequest setValue:@"text/plain; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
|
||||||
|
}
|
||||||
|
|
||||||
|
[mutableRequest setHTTPBody: [[parameters valueForKey:@"text"] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return mutableRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||||
|
self = [super initWithCoder:decoder];
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,8 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AFURLResponseSerialization.h"
|
||||||
|
|
||||||
|
@interface TextResponseSerializer : AFHTTPResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,145 @@
|
|||||||
|
#import "TextResponseSerializer.h"
|
||||||
|
|
||||||
|
static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
|
||||||
|
if (!error) {
|
||||||
|
return underlyingError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
|
||||||
|
mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||||
|
|
||||||
|
return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
|
||||||
|
if ([error.domain isEqualToString:domain] && error.code == code) {
|
||||||
|
return YES;
|
||||||
|
} else if (error.userInfo[NSUnderlyingErrorKey]) {
|
||||||
|
return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation TextResponseSerializer
|
||||||
|
|
||||||
|
+ (instancetype)serializer {
|
||||||
|
TextResponseSerializer *serializer = [[self alloc] init];
|
||||||
|
return serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
|
||||||
|
if (!self) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.acceptableContentTypes = nil;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)decodeResponseData:(NSData*)rawResponseData withEncoding:(CFStringEncoding)cfEncoding {
|
||||||
|
NSStringEncoding nsEncoding;
|
||||||
|
NSString* decoded = nil;
|
||||||
|
|
||||||
|
if (cfEncoding != kCFStringEncodingInvalidId) {
|
||||||
|
nsEncoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSStringEncoding supportedEncodings[6] = {
|
||||||
|
NSUTF8StringEncoding, NSWindowsCP1252StringEncoding, NSISOLatin1StringEncoding,
|
||||||
|
NSISOLatin2StringEncoding, NSASCIIStringEncoding, NSUnicodeStringEncoding
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(supportedEncodings) / sizeof(NSStringEncoding) && !decoded; ++i) {
|
||||||
|
if (cfEncoding == kCFStringEncodingInvalidId || nsEncoding == supportedEncodings[i]) {
|
||||||
|
decoded = [[NSString alloc] initWithData:rawResponseData encoding:supportedEncodings[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CFStringEncoding) getEncoding:(NSURLResponse *)response {
|
||||||
|
CFStringEncoding encoding = kCFStringEncodingInvalidId;
|
||||||
|
|
||||||
|
if (response.textEncodingName) {
|
||||||
|
encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
- (BOOL)validateResponse:(NSHTTPURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
decoded:(NSString **)decoded
|
||||||
|
error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
BOOL responseIsValid = YES;
|
||||||
|
NSError *validationError = nil;
|
||||||
|
|
||||||
|
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
|
if (data) {
|
||||||
|
*decoded = [self decodeResponseData:data withEncoding:[self getEncoding:response]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data && !*decoded) {
|
||||||
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
|
NSURLErrorFailingURLErrorKey:[response URL],
|
||||||
|
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
|
AFNetworkingOperationFailingURLResponseDataErrorKey: data,
|
||||||
|
AFNetworkingOperationFailingURLResponseBodyErrorKey: @"Could not decode response data due to invalid or unknown charset encoding",
|
||||||
|
} mutableCopy];
|
||||||
|
|
||||||
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
||||||
|
responseIsValid = NO;
|
||||||
|
} else if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
|
||||||
|
NSMutableDictionary *mutableUserInfo = [@{
|
||||||
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
|
||||||
|
NSURLErrorFailingURLErrorKey: [response URL],
|
||||||
|
AFNetworkingOperationFailingURLResponseErrorKey: response,
|
||||||
|
} mutableCopy];
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
|
||||||
|
mutableUserInfo[AFNetworkingOperationFailingURLResponseBodyErrorKey] = *decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
|
||||||
|
responseIsValid = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error && !responseIsValid) {
|
||||||
|
*error = validationError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseIsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - AFURLResponseSerialization
|
||||||
|
|
||||||
|
- (id)responseObjectForResponse:(NSURLResponse *)response
|
||||||
|
data:(NSData *)data
|
||||||
|
error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
NSString* decoded = nil;
|
||||||
|
|
||||||
|
if (![self validateResponse:(NSHTTPURLResponse *)response data:data decoded:&decoded error:error]) {
|
||||||
|
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,8 @@
|
|||||||
|
#import <Cordova/CDV.h>
|
||||||
|
|
||||||
|
@interface Launcher : CDVPlugin
|
||||||
|
|
||||||
|
- (void)canLaunch:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)launch:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,46 @@
|
|||||||
|
#import "Launcher.h"
|
||||||
|
#import <Cordova/CDV.h>
|
||||||
|
|
||||||
|
@implementation Launcher
|
||||||
|
|
||||||
|
- (void)canLaunch:(CDVInvokedUrlCommand*)command {
|
||||||
|
NSDictionary* options = [command.arguments objectAtIndex:0];
|
||||||
|
CDVPluginResult * pluginResult = nil;
|
||||||
|
|
||||||
|
if ([options objectForKey:@"uri"]) {
|
||||||
|
NSString *uri = [options objectForKey:@"uri"];
|
||||||
|
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:uri]]) {
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
} else {
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No app installed that can handle that uri."];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Missing option: 'uri' required."];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)launch:(CDVInvokedUrlCommand*)command {
|
||||||
|
NSDictionary* options = [command.arguments objectAtIndex:0];
|
||||||
|
CDVPluginResult * pluginResult = nil;
|
||||||
|
|
||||||
|
if ([options objectForKey:@"uri"]) {
|
||||||
|
NSString *uri = [options objectForKey:@"uri"];
|
||||||
|
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:uri]]) {
|
||||||
|
NSURL *launchURL = [NSURL URLWithString:uri];
|
||||||
|
[[UIApplication sharedApplication] openURL: launchURL];
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
} else {
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No app installed that can handle that uri."];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Missing option: 'uri' required."];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,13 @@
|
|||||||
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
@interface AppVersion : CDVPlugin
|
||||||
|
|
||||||
|
- (void)getAppName:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
- (void)getPackageName:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
- (void)getVersionNumber:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
- (void)getVersionCode:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,47 @@
|
|||||||
|
#import "AppVersion.h"
|
||||||
|
#import <Cordova/CDVPluginResult.h>
|
||||||
|
|
||||||
|
@implementation AppVersion
|
||||||
|
|
||||||
|
- (void)getAppName : (CDVInvokedUrlCommand *)command
|
||||||
|
{
|
||||||
|
NSString * callbackId = command.callbackId;
|
||||||
|
NSString * version =[[[NSBundle mainBundle]infoDictionary]objectForKey :@"CFBundleDisplayName"];
|
||||||
|
CDVPluginResult * pluginResult =[CDVPluginResult resultWithStatus : CDVCommandStatus_OK messageAsString : version];
|
||||||
|
[self.commandDelegate sendPluginResult : pluginResult callbackId : callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getPackageName:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
NSString* callbackId = command.callbackId;
|
||||||
|
NSString* packageName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
|
||||||
|
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:packageName];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getVersionNumber:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
NSString* callbackId = command.callbackId;
|
||||||
|
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
|
||||||
|
if (version == nil) {
|
||||||
|
NSLog(@"CFBundleShortVersionString was nil, attempting CFBundleVersion");
|
||||||
|
version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
||||||
|
if (version == nil) {
|
||||||
|
NSLog(@"CFBundleVersion was also nil, giving up");
|
||||||
|
// not calling error callback here to maintain backward compatibility
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getVersionCode:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
NSString* callbackId = command.callbackId;
|
||||||
|
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
||||||
|
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
@interface CDVBattery : CDVPlugin {
|
||||||
|
UIDeviceBatteryState state;
|
||||||
|
float level;
|
||||||
|
bool isPlugged;
|
||||||
|
NSString* callbackId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@property (nonatomic) UIDeviceBatteryState state;
|
||||||
|
@property (nonatomic) float level;
|
||||||
|
@property (nonatomic) bool isPlugged;
|
||||||
|
@property (strong) NSString* callbackId;
|
||||||
|
|
||||||
|
- (void)updateBatteryStatus:(NSNotification*)notification;
|
||||||
|
- (NSDictionary*)getBatteryStatus;
|
||||||
|
- (void)start:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)stop:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)dealloc;
|
||||||
|
@end
|
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "CDVBattery.h"
|
||||||
|
|
||||||
|
@interface CDVBattery (PrivateMethods)
|
||||||
|
- (void)updateOnlineStatus;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation CDVBattery
|
||||||
|
|
||||||
|
@synthesize state, level, callbackId, isPlugged;
|
||||||
|
|
||||||
|
/* determining type of event occurs on JavaScript side
|
||||||
|
- (void) updateBatteryLevel:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
// send batterylow event for less than 25% battery
|
||||||
|
// send batterycritical event for less than 10% battery
|
||||||
|
// W3c says to send batteryStatus event when batterylevel changes by more than 1% (iOS seems to notify each 5%)
|
||||||
|
// always update the navigator.device.battery info
|
||||||
|
float currentLevel = [[UIDevice currentDevice] batteryLevel];
|
||||||
|
NSString* type = @"";
|
||||||
|
// no check for level == -1 since this api is only called when monitoring is enabled so level should be valid
|
||||||
|
if (currentLevel < 0.10){
|
||||||
|
type = @"batterycritical";
|
||||||
|
} else if (currentLevel < 0.25) {
|
||||||
|
type = @"batterylow";
|
||||||
|
} else {
|
||||||
|
float onePercent = 0.1;
|
||||||
|
if (self.level >= 0 ){
|
||||||
|
onePercent = self.level * 0.01;
|
||||||
|
}
|
||||||
|
if (fabsf(currentLevel - self.level) > onePercent){
|
||||||
|
// issue batteryStatus event
|
||||||
|
type = @"batterystatus";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// update the battery info and fire event
|
||||||
|
NSString* jsString = [NSString stringWithFormat:@"navigator.device.battery._status(\"%@\", %@)", type,[[self getBatteryStatus] JSONRepresentation]];
|
||||||
|
[super writeJavascript:jsString];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (void)updateBatteryStatus:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
NSDictionary* batteryData = [self getBatteryStatus];
|
||||||
|
|
||||||
|
if (self.callbackId) {
|
||||||
|
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:batteryData];
|
||||||
|
[result setKeepCallbackAsBool:YES];
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the current battery status and level. Status will be unknown and level will be -1.0 if
|
||||||
|
* monitoring is turned off.
|
||||||
|
*/
|
||||||
|
- (NSDictionary*)getBatteryStatus
|
||||||
|
{
|
||||||
|
UIDevice* currentDevice = [UIDevice currentDevice];
|
||||||
|
UIDeviceBatteryState currentState = [currentDevice batteryState];
|
||||||
|
|
||||||
|
isPlugged = FALSE; // UIDeviceBatteryStateUnknown or UIDeviceBatteryStateUnplugged
|
||||||
|
if ((currentState == UIDeviceBatteryStateCharging) || (currentState == UIDeviceBatteryStateFull)) {
|
||||||
|
isPlugged = TRUE;
|
||||||
|
}
|
||||||
|
float currentLevel = [currentDevice batteryLevel];
|
||||||
|
|
||||||
|
if ((currentLevel != self.level) || (currentState != self.state)) {
|
||||||
|
self.level = currentLevel;
|
||||||
|
self.state = currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
// W3C spec says level must be null if it is unknown
|
||||||
|
NSObject* w3cLevel = nil;
|
||||||
|
if ((currentState == UIDeviceBatteryStateUnknown) || (currentLevel == -1.0)) {
|
||||||
|
w3cLevel = [NSNull null];
|
||||||
|
} else {
|
||||||
|
w3cLevel = [NSNumber numberWithFloat:(currentLevel * 100)];
|
||||||
|
}
|
||||||
|
NSMutableDictionary* batteryData = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||||
|
[batteryData setObject:[NSNumber numberWithBool:isPlugged] forKey:@"isPlugged"];
|
||||||
|
[batteryData setObject:w3cLevel forKey:@"level"];
|
||||||
|
return batteryData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* turn on battery monitoring*/
|
||||||
|
- (void)start:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
self.callbackId = command.callbackId;
|
||||||
|
|
||||||
|
if ([UIDevice currentDevice].batteryMonitoringEnabled == NO) {
|
||||||
|
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
|
||||||
|
name:UIDeviceBatteryStateDidChangeNotification object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
|
||||||
|
name:UIDeviceBatteryLevelDidChangeNotification object:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* turn off battery monitoring */
|
||||||
|
- (void)stop:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
// callback one last time to clear the callback function on JS side
|
||||||
|
if (self.callbackId) {
|
||||||
|
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getBatteryStatus]];
|
||||||
|
[result setKeepCallbackAsBool:NO];
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
|
||||||
|
}
|
||||||
|
self.callbackId = nil;
|
||||||
|
[[UIDevice currentDevice] setBatteryMonitoringEnabled:NO];
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryLevelDidChangeNotification object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)pluginInitialize
|
||||||
|
{
|
||||||
|
self.state = UIDeviceBatteryStateUnknown;
|
||||||
|
self.level = -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[self stop:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onReset
|
||||||
|
{
|
||||||
|
[self stop:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
@interface CDVDevice : CDVPlugin
|
||||||
|
{}
|
||||||
|
|
||||||
|
+ (NSString*)cordovaVersion;
|
||||||
|
|
||||||
|
- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
@end
|
112
platforms/ios/Aiber/Plugins/cordova-plugin-device/CDVDevice.m
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include "TargetConditionals.h"
|
||||||
|
|
||||||
|
#import <Cordova/CDV.h>
|
||||||
|
#import "CDVDevice.h"
|
||||||
|
|
||||||
|
@implementation UIDevice (ModelVersion)
|
||||||
|
|
||||||
|
- (NSString*)modelVersion
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||||
|
char* machine = malloc(size);
|
||||||
|
sysctlbyname("hw.machine", machine, &size, NULL, 0);
|
||||||
|
NSString* platform = [NSString stringWithUTF8String:machine];
|
||||||
|
free(machine);
|
||||||
|
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface CDVDevice () {}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation CDVDevice
|
||||||
|
|
||||||
|
- (NSString*)uniqueAppInstanceIdentifier:(UIDevice*)device
|
||||||
|
{
|
||||||
|
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
static NSString* UUID_KEY = @"CDVUUID";
|
||||||
|
|
||||||
|
// Check user defaults first to maintain backwards compaitibility with previous versions
|
||||||
|
// which didn't user identifierForVendor
|
||||||
|
NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
|
||||||
|
if (app_uuid == nil) {
|
||||||
|
if ([device respondsToSelector:@selector(identifierForVendor)]) {
|
||||||
|
app_uuid = [[device identifierForVendor] UUIDString];
|
||||||
|
} else {
|
||||||
|
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||||
|
app_uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid);
|
||||||
|
CFRelease(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
[userDefaults setObject:app_uuid forKey:UUID_KEY];
|
||||||
|
[userDefaults synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
return app_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
NSDictionary* deviceProperties = [self deviceProperties];
|
||||||
|
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
|
||||||
|
|
||||||
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary*)deviceProperties
|
||||||
|
{
|
||||||
|
UIDevice* device = [UIDevice currentDevice];
|
||||||
|
|
||||||
|
return @{
|
||||||
|
@"manufacturer": @"Apple",
|
||||||
|
@"model": [device modelVersion],
|
||||||
|
@"platform": @"iOS",
|
||||||
|
@"version": [device systemVersion],
|
||||||
|
@"uuid": [self uniqueAppInstanceIdentifier:device],
|
||||||
|
@"cordova": [[self class] cordovaVersion],
|
||||||
|
@"isVirtual": @([self isVirtual])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString*)cordovaVersion
|
||||||
|
{
|
||||||
|
return CDV_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isVirtual
|
||||||
|
{
|
||||||
|
#if TARGET_OS_SIMULATOR
|
||||||
|
return true;
|
||||||
|
#elif TARGET_IPHONE_SIMULATOR
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "CDVFile.h"
|
||||||
|
|
||||||
|
extern NSString* const kCDVAssetsLibraryPrefix;
|
||||||
|
extern NSString* const kCDVAssetsLibraryScheme;
|
||||||
|
|
||||||
|
@interface CDVAssetLibraryFilesystem : NSObject<CDVFileSystem> {
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithName:(NSString *)name;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,253 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "CDVFile.h"
|
||||||
|
#import "CDVAssetLibraryFilesystem.h"
|
||||||
|
#import <Cordova/CDV.h>
|
||||||
|
#import <AssetsLibrary/ALAsset.h>
|
||||||
|
#import <AssetsLibrary/ALAssetRepresentation.h>
|
||||||
|
#import <AssetsLibrary/ALAssetsLibrary.h>
|
||||||
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
|
|
||||||
|
NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
|
||||||
|
NSString* const kCDVAssetsLibraryScheme = @"assets-library";
|
||||||
|
|
||||||
|
@implementation CDVAssetLibraryFilesystem
|
||||||
|
@synthesize name=_name, urlTransformer;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
The CDVAssetLibraryFilesystem works with resources which are identified
|
||||||
|
by iOS as
|
||||||
|
asset-library://<path>
|
||||||
|
and represents them internally as URLs of the form
|
||||||
|
cdvfile://localhost/assets-library/<path>
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (NSURL *)assetLibraryURLForLocalURL:(CDVFilesystemURL *)url
|
||||||
|
{
|
||||||
|
if ([url.url.scheme isEqualToString:kCDVFilesystemURLPrefix]) {
|
||||||
|
NSString *path = [[url.url absoluteString] substringFromIndex:[@"cdvfile://localhost/assets-library" length]];
|
||||||
|
return [NSURL URLWithString:[NSString stringWithFormat:@"assets-library:/%@", path]];
|
||||||
|
}
|
||||||
|
return url.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url
|
||||||
|
{
|
||||||
|
NSDictionary* entry = [self makeEntryForLocalURL:url];
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:entry];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url {
|
||||||
|
return [self makeEntryForPath:url.fullPath isDirectory:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir
|
||||||
|
{
|
||||||
|
NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:5];
|
||||||
|
NSString* lastPart = [fullPath lastPathComponent];
|
||||||
|
if (isDir && ![fullPath hasSuffix:@"/"]) {
|
||||||
|
fullPath = [fullPath stringByAppendingString:@"/"];
|
||||||
|
}
|
||||||
|
[dirEntry setObject:[NSNumber numberWithBool:!isDir] forKey:@"isFile"];
|
||||||
|
[dirEntry setObject:[NSNumber numberWithBool:isDir] forKey:@"isDirectory"];
|
||||||
|
[dirEntry setObject:fullPath forKey:@"fullPath"];
|
||||||
|
[dirEntry setObject:lastPart forKey:@"name"];
|
||||||
|
[dirEntry setObject:self.name forKey: @"filesystemName"];
|
||||||
|
|
||||||
|
NSURL* nativeURL = [NSURL URLWithString:[NSString stringWithFormat:@"assets-library:/%@",fullPath]];
|
||||||
|
if (self.urlTransformer) {
|
||||||
|
nativeURL = self.urlTransformer(nativeURL);
|
||||||
|
}
|
||||||
|
dirEntry[@"nativeURL"] = [nativeURL absoluteString];
|
||||||
|
|
||||||
|
return dirEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* helper function to get the mimeType from the file extension
|
||||||
|
* IN:
|
||||||
|
* NSString* fullPath - filename (may include path)
|
||||||
|
* OUT:
|
||||||
|
* NSString* the mime type as type/subtype. nil if not able to determine
|
||||||
|
*/
|
||||||
|
+ (NSString*)getMimeTypeFromPath:(NSString*)fullPath
|
||||||
|
{
|
||||||
|
NSString* mimeType = nil;
|
||||||
|
|
||||||
|
if (fullPath) {
|
||||||
|
CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);
|
||||||
|
if (typeId) {
|
||||||
|
mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);
|
||||||
|
if (!mimeType) {
|
||||||
|
// special case for m4a
|
||||||
|
if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {
|
||||||
|
mimeType = @"audio/mp4";
|
||||||
|
} else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {
|
||||||
|
mimeType = @"audio/wav";
|
||||||
|
} else if ([[fullPath pathExtension] rangeOfString:@"css"].location != NSNotFound) {
|
||||||
|
mimeType = @"text/css";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CFRelease(typeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithName:(NSString *)name
|
||||||
|
{
|
||||||
|
if (self) {
|
||||||
|
self.name = name;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options
|
||||||
|
{
|
||||||
|
// return unsupported result for assets-library URLs
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getFile not supported for assets-library URLs."];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult*)getParentForURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
// we don't (yet?) support getting the parent of an asset
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options
|
||||||
|
{
|
||||||
|
// setMetadata doesn't make sense for asset library files
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
// return error for assets-library URLs
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:INVALID_MODIFICATION_ERR];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
// return error for assets-library URLs
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"removeRecursively not supported for assets-library URLs."];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
// return unsupported result for assets-library URLs
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"readEntries not supported for assets-library URLs."];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos
|
||||||
|
{
|
||||||
|
// assets-library files can't be truncated
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend
|
||||||
|
{
|
||||||
|
// text can't be written into assets-library files
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback
|
||||||
|
{
|
||||||
|
// Copying to an assets library file is not doable, since we can't write it.
|
||||||
|
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:INVALID_MODIFICATION_ERR];
|
||||||
|
callback(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)url
|
||||||
|
{
|
||||||
|
NSString *path = nil;
|
||||||
|
if ([[url.url scheme] isEqualToString:kCDVAssetsLibraryScheme]) {
|
||||||
|
path = [url.url path];
|
||||||
|
} else {
|
||||||
|
path = url.fullPath;
|
||||||
|
}
|
||||||
|
if ([path hasSuffix:@"/"]) {
|
||||||
|
path = [path substringToIndex:([path length]-1)];
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback
|
||||||
|
{
|
||||||
|
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
|
||||||
|
if (asset) {
|
||||||
|
// We have the asset! Get the data and send it off.
|
||||||
|
ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
|
||||||
|
NSUInteger size = (end > start) ? (end - start) : [assetRepresentation size];
|
||||||
|
Byte* buffer = (Byte*)malloc(size);
|
||||||
|
NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:start length:size error:nil];
|
||||||
|
NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
|
||||||
|
NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
|
||||||
|
|
||||||
|
callback(data, MIMEType, NO_ERROR);
|
||||||
|
} else {
|
||||||
|
callback(nil, nil, NOT_FOUND_ERR);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
|
||||||
|
// Retrieving the asset failed for some reason. Send the appropriate error.
|
||||||
|
NSLog(@"Error: %@", error);
|
||||||
|
callback(nil, nil, SECURITY_ERR);
|
||||||
|
};
|
||||||
|
|
||||||
|
ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
|
||||||
|
[assetsLibrary assetForURL:[self assetLibraryURLForLocalURL:localURL] resultBlock:resultBlock failureBlock:failureBlock];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback
|
||||||
|
{
|
||||||
|
// In this case, we need to use an asynchronous method to retrieve the file.
|
||||||
|
// Because of this, we can't just assign to `result` and send it at the end of the method.
|
||||||
|
// Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
|
||||||
|
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
|
||||||
|
if (asset) {
|
||||||
|
// We have the asset! Populate the dictionary and send it off.
|
||||||
|
NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
|
||||||
|
ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
|
||||||
|
[fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[assetRepresentation size]] forKey:@"size"];
|
||||||
|
[fileInfo setObject:localURL.fullPath forKey:@"fullPath"];
|
||||||
|
NSString* filename = [assetRepresentation filename];
|
||||||
|
[fileInfo setObject:filename forKey:@"name"];
|
||||||
|
[fileInfo setObject:[CDVAssetLibraryFilesystem getMimeTypeFromPath:filename] forKey:@"type"];
|
||||||
|
NSDate* creationDate = [asset valueForProperty:ALAssetPropertyDate];
|
||||||
|
NSNumber* msDate = [NSNumber numberWithDouble:[creationDate timeIntervalSince1970] * 1000];
|
||||||
|
[fileInfo setObject:msDate forKey:@"lastModifiedDate"];
|
||||||
|
|
||||||
|
callback([CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo]);
|
||||||
|
} else {
|
||||||
|
// We couldn't find the asset. Send the appropriate error.
|
||||||
|
callback([CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
|
||||||
|
// Retrieving the asset failed for some reason. Send the appropriate error.
|
||||||
|
callback([CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]]);
|
||||||
|
};
|
||||||
|
|
||||||
|
ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
|
||||||
|
[assetsLibrary assetForURL:[self assetLibraryURLForLocalURL:localURL] resultBlock:resultBlock failureBlock:failureBlock];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@end
|
157
platforms/ios/Aiber/Plugins/cordova-plugin-file/CDVFile.h
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
extern NSString* const kCDVAssetsLibraryPrefix;
|
||||||
|
extern NSString* const kCDVFilesystemURLPrefix;
|
||||||
|
|
||||||
|
enum CDVFileError {
|
||||||
|
NO_ERROR = 0,
|
||||||
|
NOT_FOUND_ERR = 1,
|
||||||
|
SECURITY_ERR = 2,
|
||||||
|
ABORT_ERR = 3,
|
||||||
|
NOT_READABLE_ERR = 4,
|
||||||
|
ENCODING_ERR = 5,
|
||||||
|
NO_MODIFICATION_ALLOWED_ERR = 6,
|
||||||
|
INVALID_STATE_ERR = 7,
|
||||||
|
SYNTAX_ERR = 8,
|
||||||
|
INVALID_MODIFICATION_ERR = 9,
|
||||||
|
QUOTA_EXCEEDED_ERR = 10,
|
||||||
|
TYPE_MISMATCH_ERR = 11,
|
||||||
|
PATH_EXISTS_ERR = 12
|
||||||
|
};
|
||||||
|
typedef int CDVFileError;
|
||||||
|
|
||||||
|
@interface CDVFilesystemURL : NSObject {
|
||||||
|
NSURL *_url;
|
||||||
|
NSString *_fileSystemName;
|
||||||
|
NSString *_fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithString:(NSString*)strURL;
|
||||||
|
- (id) initWithURL:(NSURL*)URL;
|
||||||
|
+ (CDVFilesystemURL *)fileSystemURLWithString:(NSString *)strURL;
|
||||||
|
+ (CDVFilesystemURL *)fileSystemURLWithURL:(NSURL *)URL;
|
||||||
|
|
||||||
|
- (NSString *)absoluteURL;
|
||||||
|
|
||||||
|
@property (atomic) NSURL *url;
|
||||||
|
@property (atomic) NSString *fileSystemName;
|
||||||
|
@property (atomic) NSString *fullPath;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface CDVFilesystemURLProtocol : NSURLProtocol
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol CDVFileSystem
|
||||||
|
- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url;
|
||||||
|
- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options;
|
||||||
|
- (CDVPluginResult *)getParentForURL:(CDVFilesystemURL *)localURI;
|
||||||
|
- (CDVPluginResult *)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options;
|
||||||
|
- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI;
|
||||||
|
- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI;
|
||||||
|
- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI;
|
||||||
|
- (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos;
|
||||||
|
- (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend;
|
||||||
|
- (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback;
|
||||||
|
- (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback;
|
||||||
|
- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback;
|
||||||
|
|
||||||
|
- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url;
|
||||||
|
- (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir;
|
||||||
|
|
||||||
|
@property (nonatomic,strong) NSString *name;
|
||||||
|
@property (nonatomic, copy) NSURL*(^urlTransformer)(NSURL*);
|
||||||
|
|
||||||
|
@optional
|
||||||
|
- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)localURI;
|
||||||
|
- (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface CDVFile : CDVPlugin {
|
||||||
|
NSString* rootDocsPath;
|
||||||
|
NSString* appDocsPath;
|
||||||
|
NSString* appLibraryPath;
|
||||||
|
NSString* appTempPath;
|
||||||
|
|
||||||
|
NSMutableArray* fileSystems_;
|
||||||
|
BOOL userHasAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;
|
||||||
|
- (NSDictionary*)makeEntryForPath:(NSString*)fullPath fileSystemName:(NSString *)fsName isDirectory:(BOOL)isDir;
|
||||||
|
- (NSDictionary *)makeEntryForURL:(NSURL *)URL;
|
||||||
|
- (CDVFilesystemURL *)fileSystemURLforLocalPath:(NSString *)localPath;
|
||||||
|
|
||||||
|
- (NSObject<CDVFileSystem> *)filesystemForURL:(CDVFilesystemURL *)localURL;
|
||||||
|
|
||||||
|
/* Native Registration API */
|
||||||
|
- (void)registerFilesystem:(NSObject<CDVFileSystem> *)fs;
|
||||||
|
- (NSObject<CDVFileSystem> *)fileSystemByName:(NSString *)fsName;
|
||||||
|
|
||||||
|
/* Exec API */
|
||||||
|
- (void)requestFileSystem:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)getDirectory:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)getFile:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)getParent:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)removeRecursively:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)remove:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)copyTo:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)moveTo:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)getFileMetadata:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)readEntries:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)readAsText:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)readAsDataURL:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)write:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)testFileExists:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)truncate:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;
|
||||||
|
|
||||||
|
/* Compatibilty with older File API */
|
||||||
|
- (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
|
||||||
|
- (NSDictionary *)getDirectoryEntry:(NSString *)target isDirectory:(BOOL)bDirRequest;
|
||||||
|
|
||||||
|
/* Conversion between filesystem paths and URLs */
|
||||||
|
- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)URL;
|
||||||
|
|
||||||
|
/* Internal methods for testing */
|
||||||
|
- (void)_getLocalFilesystemPath:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
@property (nonatomic, strong) NSString* rootDocsPath;
|
||||||
|
@property (nonatomic, strong) NSString* appDocsPath;
|
||||||
|
@property (nonatomic, strong) NSString* appLibraryPath;
|
||||||
|
@property (nonatomic, strong) NSString* appTempPath;
|
||||||
|
@property (nonatomic, strong) NSString* persistentPath;
|
||||||
|
@property (nonatomic, strong) NSString* temporaryPath;
|
||||||
|
@property (nonatomic, strong) NSMutableArray* fileSystems;
|
||||||
|
|
||||||
|
@property BOOL userHasAllowed;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#define kW3FileTemporary @"temporary"
|
||||||
|
#define kW3FilePersistent @"persistent"
|
1119
platforms/ios/Aiber/Plugins/cordova-plugin-file/CDVFile.m
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "CDVFile.h"
|
||||||
|
|
||||||
|
@interface CDVLocalFilesystem : NSObject<CDVFileSystem> {
|
||||||
|
NSString *_name;
|
||||||
|
NSString *_fsRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithName:(NSString *)name root:(NSString *)fsRoot;
|
||||||
|
+ (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
|
||||||
|
|
||||||
|
@property (nonatomic,strong) NSString *fsRoot;
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,750 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "CDVFile.h"
|
||||||
|
#import "CDVLocalFilesystem.h"
|
||||||
|
#import <Cordova/CDV.h>
|
||||||
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
|
#import <sys/xattr.h>
|
||||||
|
|
||||||
|
@implementation CDVLocalFilesystem
|
||||||
|
@synthesize name=_name, fsRoot=_fsRoot, urlTransformer;
|
||||||
|
|
||||||
|
- (id) initWithName:(NSString *)name root:(NSString *)fsRoot
|
||||||
|
{
|
||||||
|
if (self) {
|
||||||
|
self.name = name;
|
||||||
|
self.fsRoot = fsRoot;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IN
|
||||||
|
* NSString localURI
|
||||||
|
* OUT
|
||||||
|
* CDVPluginResult result containing a file or directoryEntry for the localURI, or an error if the
|
||||||
|
* URI represents a non-existent path, or is unrecognized or otherwise malformed.
|
||||||
|
*/
|
||||||
|
- (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url
|
||||||
|
{
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
NSDictionary* entry = [self makeEntryForLocalURL:url];
|
||||||
|
if (entry) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:entry];
|
||||||
|
} else {
|
||||||
|
// return NOT_FOUND_ERR
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
- (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url {
|
||||||
|
NSString *path = [self filesystemPathForURL:url];
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
BOOL isDir = NO;
|
||||||
|
// see if exists and is file or dir
|
||||||
|
BOOL bExists = [fileMgr fileExistsAtPath:path isDirectory:&isDir];
|
||||||
|
if (bExists) {
|
||||||
|
return [self makeEntryForPath:url.fullPath isDirectory:isDir];
|
||||||
|
} else {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir
|
||||||
|
{
|
||||||
|
NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:5];
|
||||||
|
NSString* lastPart = [[self stripQueryParametersFromPath:fullPath] lastPathComponent];
|
||||||
|
if (isDir && ![fullPath hasSuffix:@"/"]) {
|
||||||
|
fullPath = [fullPath stringByAppendingString:@"/"];
|
||||||
|
}
|
||||||
|
[dirEntry setObject:[NSNumber numberWithBool:!isDir] forKey:@"isFile"];
|
||||||
|
[dirEntry setObject:[NSNumber numberWithBool:isDir] forKey:@"isDirectory"];
|
||||||
|
[dirEntry setObject:fullPath forKey:@"fullPath"];
|
||||||
|
[dirEntry setObject:lastPart forKey:@"name"];
|
||||||
|
[dirEntry setObject:self.name forKey: @"filesystemName"];
|
||||||
|
|
||||||
|
NSURL* nativeURL = [NSURL fileURLWithPath:[self filesystemPathForFullPath:fullPath]];
|
||||||
|
if (self.urlTransformer) {
|
||||||
|
nativeURL = self.urlTransformer(nativeURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
dirEntry[@"nativeURL"] = [nativeURL absoluteString];
|
||||||
|
|
||||||
|
return dirEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)stripQueryParametersFromPath:(NSString *)fullPath
|
||||||
|
{
|
||||||
|
NSRange questionMark = [fullPath rangeOfString:@"?"];
|
||||||
|
if (questionMark.location != NSNotFound) {
|
||||||
|
return [fullPath substringWithRange:NSMakeRange(0,questionMark.location)];
|
||||||
|
}
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)filesystemPathForFullPath:(NSString *)fullPath
|
||||||
|
{
|
||||||
|
NSString *path = nil;
|
||||||
|
NSString *strippedFullPath = [self stripQueryParametersFromPath:fullPath];
|
||||||
|
path = [NSString stringWithFormat:@"%@%@", self.fsRoot, strippedFullPath];
|
||||||
|
if ([path length] > 1 && [path hasSuffix:@"/"]) {
|
||||||
|
path = [path substringToIndex:([path length]-1)];
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* IN
|
||||||
|
* NSString localURI
|
||||||
|
* OUT
|
||||||
|
* NSString full local filesystem path for the represented file or directory, or nil if no such path is possible
|
||||||
|
* The file or directory does not necessarily have to exist. nil is returned if the filesystem type is not recognized,
|
||||||
|
* or if the URL is malformed.
|
||||||
|
* The incoming URI should be properly escaped (no raw spaces, etc. URI percent-encoding is expected).
|
||||||
|
*/
|
||||||
|
- (NSString *)filesystemPathForURL:(CDVFilesystemURL *)url
|
||||||
|
{
|
||||||
|
return [self filesystemPathForFullPath:url.fullPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVFilesystemURL *)URLforFullPath:(NSString *)fullPath
|
||||||
|
{
|
||||||
|
if (fullPath) {
|
||||||
|
NSString* escapedPath = [fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
if ([fullPath hasPrefix:@"/"]) {
|
||||||
|
return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@%@", kCDVFilesystemURLPrefix, self.name, escapedPath]];
|
||||||
|
}
|
||||||
|
return [CDVFilesystemURL fileSystemURLWithString:[NSString stringWithFormat:@"%@://localhost/%@/%@", kCDVFilesystemURLPrefix, self.name, escapedPath]];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path
|
||||||
|
{
|
||||||
|
return [self URLforFullPath:[self fullPathForFileSystemPath:path]];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)normalizePath:(NSString *)rawPath
|
||||||
|
{
|
||||||
|
// If this is an absolute path, the first path component will be '/'. Skip it if that's the case
|
||||||
|
BOOL isAbsolutePath = [rawPath hasPrefix:@"/"];
|
||||||
|
if (isAbsolutePath) {
|
||||||
|
rawPath = [rawPath substringFromIndex:1];
|
||||||
|
}
|
||||||
|
NSMutableArray *components = [NSMutableArray arrayWithArray:[rawPath pathComponents]];
|
||||||
|
for (int index = 0; index < [components count]; ++index) {
|
||||||
|
if ([[components objectAtIndex:index] isEqualToString:@".."]) {
|
||||||
|
[components removeObjectAtIndex:index];
|
||||||
|
if (index > 0) {
|
||||||
|
[components removeObjectAtIndex:index-1];
|
||||||
|
--index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAbsolutePath) {
|
||||||
|
return [NSString stringWithFormat:@"/%@", [components componentsJoinedByString:@"/"]];
|
||||||
|
} else {
|
||||||
|
return [components componentsJoinedByString:@"/"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)valueForKeyIsNumber:(NSDictionary*)dict key:(NSString*)key
|
||||||
|
{
|
||||||
|
BOOL bNumber = NO;
|
||||||
|
NSObject* value = dict[key];
|
||||||
|
if (value) {
|
||||||
|
bNumber = [value isKindOfClass:[NSNumber class]];
|
||||||
|
}
|
||||||
|
return bNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options
|
||||||
|
{
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
BOOL bDirRequest = NO;
|
||||||
|
BOOL create = NO;
|
||||||
|
BOOL exclusive = NO;
|
||||||
|
int errorCode = 0; // !!! risky - no error code currently defined for 0
|
||||||
|
|
||||||
|
if ([self valueForKeyIsNumber:options key:@"create"]) {
|
||||||
|
create = [(NSNumber*)[options valueForKey:@"create"] boolValue];
|
||||||
|
}
|
||||||
|
if ([self valueForKeyIsNumber:options key:@"exclusive"]) {
|
||||||
|
exclusive = [(NSNumber*)[options valueForKey:@"exclusive"] boolValue];
|
||||||
|
}
|
||||||
|
if ([self valueForKeyIsNumber:options key:@"getDir"]) {
|
||||||
|
// this will not exist for calls directly to getFile but will have been set by getDirectory before calling this method
|
||||||
|
bDirRequest = [(NSNumber*)[options valueForKey:@"getDir"] boolValue];
|
||||||
|
}
|
||||||
|
// see if the requested path has invalid characters - should we be checking for more than just ":"?
|
||||||
|
if ([requestedPath rangeOfString:@":"].location != NSNotFound) {
|
||||||
|
errorCode = ENCODING_ERR;
|
||||||
|
} else {
|
||||||
|
// Build new fullPath for the requested resource.
|
||||||
|
// We concatenate the two paths together, and then scan the resulting string to remove
|
||||||
|
// parent ("..") references. Any parent references at the beginning of the string are
|
||||||
|
// silently removed.
|
||||||
|
NSString *combinedPath = [baseURI.fullPath stringByAppendingPathComponent:requestedPath];
|
||||||
|
combinedPath = [self normalizePath:combinedPath];
|
||||||
|
CDVFilesystemURL* requestedURL = [self URLforFullPath:combinedPath];
|
||||||
|
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
BOOL bIsDir;
|
||||||
|
BOOL bExists = [fileMgr fileExistsAtPath:[self filesystemPathForURL:requestedURL] isDirectory:&bIsDir];
|
||||||
|
if (bExists && (create == NO) && (bIsDir == !bDirRequest)) {
|
||||||
|
// path exists and is not of requested type - return TYPE_MISMATCH_ERR
|
||||||
|
errorCode = TYPE_MISMATCH_ERR;
|
||||||
|
} else if (!bExists && (create == NO)) {
|
||||||
|
// path does not exist and create is false - return NOT_FOUND_ERR
|
||||||
|
errorCode = NOT_FOUND_ERR;
|
||||||
|
} else if (bExists && (create == YES) && (exclusive == YES)) {
|
||||||
|
// file/dir already exists and exclusive and create are both true - return PATH_EXISTS_ERR
|
||||||
|
errorCode = PATH_EXISTS_ERR;
|
||||||
|
} else {
|
||||||
|
// if bExists and create == YES - just return data
|
||||||
|
// if bExists and create == NO - just return data
|
||||||
|
// if !bExists and create == YES - create and return data
|
||||||
|
BOOL bSuccess = YES;
|
||||||
|
NSError __autoreleasing* pError = nil;
|
||||||
|
if (!bExists && (create == YES)) {
|
||||||
|
if (bDirRequest) {
|
||||||
|
// create the dir
|
||||||
|
bSuccess = [fileMgr createDirectoryAtPath:[self filesystemPathForURL:requestedURL] withIntermediateDirectories:NO attributes:nil error:&pError];
|
||||||
|
} else {
|
||||||
|
// create the empty file
|
||||||
|
bSuccess = [fileMgr createFileAtPath:[self filesystemPathForURL:requestedURL] contents:nil attributes:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bSuccess) {
|
||||||
|
errorCode = ABORT_ERR;
|
||||||
|
if (pError) {
|
||||||
|
NSLog(@"error creating directory: %@", [pError localizedDescription]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// NSLog(@"newly created file/dir (%@) exists: %d", reqFullPath, [fileMgr fileExistsAtPath:reqFullPath]);
|
||||||
|
// file existed or was created
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self makeEntryForPath:requestedURL.fullPath isDirectory:bDirRequest]];
|
||||||
|
}
|
||||||
|
} // are all possible conditions met?
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCode > 0) {
|
||||||
|
// create error callback
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult*)getParentForURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
CDVFilesystemURL *newURI = nil;
|
||||||
|
if ([localURI.fullPath isEqualToString:@""]) {
|
||||||
|
// return self
|
||||||
|
newURI = localURI;
|
||||||
|
} else {
|
||||||
|
newURI = [CDVFilesystemURL fileSystemURLWithURL:[localURI.url URLByDeletingLastPathComponent]]; /* TODO: UGLY - FIX */
|
||||||
|
}
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
BOOL bIsDir;
|
||||||
|
BOOL bExists = [fileMgr fileExistsAtPath:[self filesystemPathForURL:newURI] isDirectory:&bIsDir];
|
||||||
|
if (bExists) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self makeEntryForPath:newURI.fullPath isDirectory:bIsDir]];
|
||||||
|
} else {
|
||||||
|
// invalid path or file does not exist
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult*)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options
|
||||||
|
{
|
||||||
|
BOOL ok = NO;
|
||||||
|
|
||||||
|
NSString* filePath = [self filesystemPathForURL:localURI];
|
||||||
|
// we only care about this iCloud key for now.
|
||||||
|
// set to 1/true to skip backup, set to 0/false to back it up (effectively removing the attribute)
|
||||||
|
NSString* iCloudBackupExtendedAttributeKey = @"com.apple.MobileBackup";
|
||||||
|
id iCloudBackupExtendedAttributeValue = [options objectForKey:iCloudBackupExtendedAttributeKey];
|
||||||
|
|
||||||
|
if ((iCloudBackupExtendedAttributeValue != nil) && [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]]) {
|
||||||
|
if (IsAtLeastiOSVersion(@"5.1")) {
|
||||||
|
NSURL* url = [NSURL fileURLWithPath:filePath];
|
||||||
|
NSError* __autoreleasing error = nil;
|
||||||
|
|
||||||
|
ok = [url setResourceValue:[NSNumber numberWithBool:[iCloudBackupExtendedAttributeValue boolValue]] forKey:NSURLIsExcludedFromBackupKey error:&error];
|
||||||
|
} else { // below 5.1 (deprecated - only really supported in 5.01)
|
||||||
|
u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];
|
||||||
|
if (value == 0) { // remove the attribute (allow backup, the default)
|
||||||
|
ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);
|
||||||
|
} else { // set the attribute (skip backup)
|
||||||
|
ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
} else {
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove the file or directory (recursively)
|
||||||
|
* IN:
|
||||||
|
* NSString* fullPath - the full path to the file or directory to be removed
|
||||||
|
* NSString* callbackId
|
||||||
|
* called from remove and removeRecursively - check all pubic api specific error conditions (dir not empty, etc) before calling
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (CDVPluginResult*)doRemove:(NSString*)fullPath
|
||||||
|
{
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
BOOL bSuccess = NO;
|
||||||
|
NSError* __autoreleasing pError = nil;
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
bSuccess = [fileMgr removeItemAtPath:fullPath error:&pError];
|
||||||
|
if (bSuccess) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
} else {
|
||||||
|
// see if we can give a useful error
|
||||||
|
CDVFileError errorCode = ABORT_ERR;
|
||||||
|
NSLog(@"error removing filesystem entry at %@: %@", fullPath, [pError localizedDescription]);
|
||||||
|
if ([pError code] == NSFileNoSuchFileError) {
|
||||||
|
errorCode = NOT_FOUND_ERR;
|
||||||
|
} else if ([pError code] == NSFileWriteNoPermissionError) {
|
||||||
|
errorCode = NO_MODIFICATION_ALLOWED_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
|
||||||
|
}
|
||||||
|
} @catch(NSException* e) { // NSInvalidArgumentException if path is . or ..
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SYNTAX_ERR];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
NSString *fileSystemPath = [self filesystemPathForURL:localURI];
|
||||||
|
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
BOOL bIsDir = NO;
|
||||||
|
BOOL bExists = [fileMgr fileExistsAtPath:fileSystemPath isDirectory:&bIsDir];
|
||||||
|
if (!bExists) {
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
|
||||||
|
}
|
||||||
|
if (bIsDir && ([[fileMgr contentsOfDirectoryAtPath:fileSystemPath error:nil] count] != 0)) {
|
||||||
|
// dir is not empty
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:INVALID_MODIFICATION_ERR];
|
||||||
|
}
|
||||||
|
return [self doRemove:fileSystemPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
NSString *fileSystemPath = [self filesystemPathForURL:localURI];
|
||||||
|
return [self doRemove:fileSystemPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IN
|
||||||
|
* NSString localURI
|
||||||
|
* OUT
|
||||||
|
* NSString full local filesystem path for the represented file or directory, or nil if no such path is possible
|
||||||
|
* The file or directory does not necessarily have to exist. nil is returned if the filesystem type is not recognized,
|
||||||
|
* or if the URL is malformed.
|
||||||
|
* The incoming URI should be properly escaped (no raw spaces, etc. URI percent-encoding is expected).
|
||||||
|
*/
|
||||||
|
- (NSString *)fullPathForFileSystemPath:(NSString *)fsPath
|
||||||
|
{
|
||||||
|
if ([fsPath hasPrefix:self.fsRoot]) {
|
||||||
|
return [fsPath substringFromIndex:[self.fsRoot length]];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI
|
||||||
|
{
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
NSError* __autoreleasing error = nil;
|
||||||
|
NSString *fileSystemPath = [self filesystemPathForURL:localURI];
|
||||||
|
|
||||||
|
NSArray* contents = [fileMgr contentsOfDirectoryAtPath:fileSystemPath error:&error];
|
||||||
|
|
||||||
|
if (contents) {
|
||||||
|
NSMutableArray* entries = [NSMutableArray arrayWithCapacity:1];
|
||||||
|
if ([contents count] > 0) {
|
||||||
|
// create an Entry (as JSON) for each file/dir
|
||||||
|
for (NSString* name in contents) {
|
||||||
|
// see if is dir or file
|
||||||
|
NSString* entryPath = [fileSystemPath stringByAppendingPathComponent:name];
|
||||||
|
BOOL bIsDir = NO;
|
||||||
|
[fileMgr fileExistsAtPath:entryPath isDirectory:&bIsDir];
|
||||||
|
NSDictionary* entryDict = [self makeEntryForPath:[self fullPathForFileSystemPath:entryPath] isDirectory:bIsDir];
|
||||||
|
[entries addObject:entryDict];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:entries];
|
||||||
|
} else {
|
||||||
|
// assume not found but could check error for more specific error conditions
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos
|
||||||
|
{
|
||||||
|
unsigned long long newPos = 0UL;
|
||||||
|
|
||||||
|
NSFileHandle* file = [NSFileHandle fileHandleForWritingAtPath:filePath];
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
[file truncateFileAtOffset:(unsigned long long)pos];
|
||||||
|
newPos = [file offsetInFile];
|
||||||
|
[file synchronizeFile];
|
||||||
|
[file closeFile];
|
||||||
|
}
|
||||||
|
return newPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos
|
||||||
|
{
|
||||||
|
unsigned long long newPos = [self truncateFile:[self filesystemPathForURL:localURI] atPosition:pos];
|
||||||
|
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)newPos];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend
|
||||||
|
{
|
||||||
|
NSString *filePath = [self filesystemPathForURL:localURL];
|
||||||
|
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
CDVFileError errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
int bytesWritten = 0;
|
||||||
|
|
||||||
|
if (filePath) {
|
||||||
|
NSOutputStream* fileStream = [NSOutputStream outputStreamToFileAtPath:filePath append:shouldAppend];
|
||||||
|
if (fileStream) {
|
||||||
|
NSUInteger len = [encData length];
|
||||||
|
if (len == 0) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:(double)len];
|
||||||
|
} else {
|
||||||
|
[fileStream open];
|
||||||
|
|
||||||
|
bytesWritten = (int)[fileStream write:[encData bytes] maxLength:len];
|
||||||
|
|
||||||
|
[fileStream close];
|
||||||
|
if (bytesWritten > 0) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];
|
||||||
|
// } else {
|
||||||
|
// can probably get more detailed error info via [fileStream streamError]
|
||||||
|
// errCode already set to INVALID_MODIFICATION_ERR;
|
||||||
|
// bytesWritten = 0; // may be set to -1 on error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // else fileStream not created return INVALID_MODIFICATION_ERR
|
||||||
|
} else {
|
||||||
|
// invalid filePath
|
||||||
|
errCode = NOT_FOUND_ERR;
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
// was an error
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to check to see if the user attempted to copy an entry into its parent without changing its name,
|
||||||
|
* or attempted to copy a directory into a directory that it contains directly or indirectly.
|
||||||
|
*
|
||||||
|
* IN:
|
||||||
|
* NSString* srcDir
|
||||||
|
* NSString* destinationDir
|
||||||
|
* OUT:
|
||||||
|
* YES copy/ move is allows
|
||||||
|
* NO move is onto itself
|
||||||
|
*/
|
||||||
|
- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest
|
||||||
|
{
|
||||||
|
// This weird test is to determine if we are copying or moving a directory into itself.
|
||||||
|
// Copy /Documents/myDir to /Documents/myDir-backup is okay but
|
||||||
|
// Copy /Documents/myDir to /Documents/myDir/backup not okay
|
||||||
|
BOOL copyOK = YES;
|
||||||
|
NSRange range = [dest rangeOfString:src];
|
||||||
|
|
||||||
|
if (range.location != NSNotFound) {
|
||||||
|
NSRange testRange = {range.length - 1, ([dest length] - range.length)};
|
||||||
|
NSRange resultRange = [dest rangeOfString:@"/" options:0 range:testRange];
|
||||||
|
if (resultRange.location != NSNotFound) {
|
||||||
|
copyOK = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return copyOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback
|
||||||
|
{
|
||||||
|
NSFileManager *fileMgr = [[NSFileManager alloc] init];
|
||||||
|
NSString *destRootPath = [self filesystemPathForURL:destURL];
|
||||||
|
BOOL bDestIsDir = NO;
|
||||||
|
BOOL bDestExists = [fileMgr fileExistsAtPath:destRootPath isDirectory:&bDestIsDir];
|
||||||
|
|
||||||
|
NSString *newFileSystemPath = [destRootPath stringByAppendingPathComponent:newName];
|
||||||
|
NSString *newFullPath = [self fullPathForFileSystemPath:newFileSystemPath];
|
||||||
|
|
||||||
|
BOOL bNewIsDir = NO;
|
||||||
|
BOOL bNewExists = [fileMgr fileExistsAtPath:newFileSystemPath isDirectory:&bNewIsDir];
|
||||||
|
|
||||||
|
CDVPluginResult *result = nil;
|
||||||
|
int errCode = 0;
|
||||||
|
|
||||||
|
if (!bDestExists) {
|
||||||
|
// the destination root does not exist
|
||||||
|
errCode = NOT_FOUND_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ([srcFs isKindOfClass:[CDVLocalFilesystem class]]) {
|
||||||
|
/* Same FS, we can shortcut with NSFileManager operations */
|
||||||
|
NSString *srcFullPath = [srcFs filesystemPathForURL:srcURL];
|
||||||
|
|
||||||
|
BOOL bSrcIsDir = NO;
|
||||||
|
BOOL bSrcExists = [fileMgr fileExistsAtPath:srcFullPath isDirectory:&bSrcIsDir];
|
||||||
|
|
||||||
|
if (!bSrcExists) {
|
||||||
|
// the source does not exist
|
||||||
|
errCode = NOT_FOUND_ERR;
|
||||||
|
} else if ([newFileSystemPath isEqualToString:srcFullPath]) {
|
||||||
|
// source and destination can not be the same
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
} else if (bSrcIsDir && (bNewExists && !bNewIsDir)) {
|
||||||
|
// can't copy/move dir to file
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
} else { // no errors yet
|
||||||
|
NSError* __autoreleasing error = nil;
|
||||||
|
BOOL bSuccess = NO;
|
||||||
|
if (bCopy) {
|
||||||
|
if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFileSystemPath]) {
|
||||||
|
// can't copy dir into self
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
} else if (bNewExists) {
|
||||||
|
// the full destination should NOT already exist if a copy
|
||||||
|
errCode = PATH_EXISTS_ERR;
|
||||||
|
} else {
|
||||||
|
bSuccess = [fileMgr copyItemAtPath:srcFullPath toPath:newFileSystemPath error:&error];
|
||||||
|
}
|
||||||
|
} else { // move
|
||||||
|
// iOS requires that destination must not exist before calling moveTo
|
||||||
|
// is W3C INVALID_MODIFICATION_ERR error if destination dir exists and has contents
|
||||||
|
//
|
||||||
|
if (!bSrcIsDir && (bNewExists && bNewIsDir)) {
|
||||||
|
// can't move a file to directory
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
} else if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFileSystemPath]) {
|
||||||
|
// can't move a dir into itself
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
} else if (bNewExists) {
|
||||||
|
if (bNewIsDir && ([[fileMgr contentsOfDirectoryAtPath:newFileSystemPath error:NULL] count] != 0)) {
|
||||||
|
// can't move dir to a dir that is not empty
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
newFileSystemPath = nil; // so we won't try to move
|
||||||
|
} else {
|
||||||
|
// remove destination so can perform the moveItemAtPath
|
||||||
|
bSuccess = [fileMgr removeItemAtPath:newFileSystemPath error:NULL];
|
||||||
|
if (!bSuccess) {
|
||||||
|
errCode = INVALID_MODIFICATION_ERR; // is this the correct error?
|
||||||
|
newFileSystemPath = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (bNewIsDir && [newFileSystemPath hasPrefix:srcFullPath]) {
|
||||||
|
// can't move a directory inside itself or to any child at any depth;
|
||||||
|
errCode = INVALID_MODIFICATION_ERR;
|
||||||
|
newFileSystemPath = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newFileSystemPath != nil) {
|
||||||
|
bSuccess = [fileMgr moveItemAtPath:srcFullPath toPath:newFileSystemPath error:&error];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bSuccess) {
|
||||||
|
// should verify it is there and of the correct type???
|
||||||
|
NSDictionary* newEntry = [self makeEntryForPath:newFullPath isDirectory:bSrcIsDir];
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];
|
||||||
|
} else {
|
||||||
|
if (error) {
|
||||||
|
if (([error code] == NSFileReadUnknownError) || ([error code] == NSFileReadTooLargeError)) {
|
||||||
|
errCode = NOT_READABLE_ERR;
|
||||||
|
} else if ([error code] == NSFileWriteOutOfSpaceError) {
|
||||||
|
errCode = QUOTA_EXCEEDED_ERR;
|
||||||
|
} else if ([error code] == NSFileWriteNoPermissionError) {
|
||||||
|
errCode = NO_MODIFICATION_ALLOWED_ERR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Need to copy the hard way
|
||||||
|
[srcFs readFileAtURL:srcURL start:0 end:-1 callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
if (data != nil) {
|
||||||
|
BOOL bSuccess = [data writeToFile:newFileSystemPath atomically:YES];
|
||||||
|
if (bSuccess) {
|
||||||
|
// should verify it is there and of the correct type???
|
||||||
|
NSDictionary* newEntry = [self makeEntryForPath:newFullPath isDirectory:NO];
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];
|
||||||
|
} else {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ABORT_ERR];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
|
||||||
|
}
|
||||||
|
callback(result);
|
||||||
|
}];
|
||||||
|
return; // Async IO; return without callback.
|
||||||
|
}
|
||||||
|
if (result == nil) {
|
||||||
|
if (!errCode) {
|
||||||
|
errCode = INVALID_MODIFICATION_ERR; // Catch-all default
|
||||||
|
}
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errCode];
|
||||||
|
}
|
||||||
|
callback(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* helper function to get the mimeType from the file extension
|
||||||
|
* IN:
|
||||||
|
* NSString* fullPath - filename (may include path)
|
||||||
|
* OUT:
|
||||||
|
* NSString* the mime type as type/subtype. nil if not able to determine
|
||||||
|
*/
|
||||||
|
+ (NSString*)getMimeTypeFromPath:(NSString*)fullPath
|
||||||
|
{
|
||||||
|
NSString* mimeType = nil;
|
||||||
|
|
||||||
|
if (fullPath) {
|
||||||
|
CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);
|
||||||
|
if (typeId) {
|
||||||
|
mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);
|
||||||
|
if (!mimeType) {
|
||||||
|
// special case for m4a
|
||||||
|
if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {
|
||||||
|
mimeType = @"audio/mp4";
|
||||||
|
} else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {
|
||||||
|
mimeType = @"audio/wav";
|
||||||
|
} else if ([[fullPath pathExtension] rangeOfString:@"css"].location != NSNotFound) {
|
||||||
|
mimeType = @"text/css";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CFRelease(typeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback
|
||||||
|
{
|
||||||
|
NSString *path = [self filesystemPathForURL:localURL];
|
||||||
|
|
||||||
|
NSString* mimeType = [CDVLocalFilesystem getMimeTypeFromPath:path];
|
||||||
|
if (mimeType == nil) {
|
||||||
|
mimeType = @"*/*";
|
||||||
|
}
|
||||||
|
NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:path];
|
||||||
|
if (start > 0) {
|
||||||
|
[file seekToFileOffset:start];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSData* readData;
|
||||||
|
if (end < 0) {
|
||||||
|
readData = [file readDataToEndOfFile];
|
||||||
|
} else {
|
||||||
|
readData = [file readDataOfLength:(end - start)];
|
||||||
|
}
|
||||||
|
[file closeFile];
|
||||||
|
|
||||||
|
callback(readData, mimeType, readData != nil ? NO_ERROR : NOT_FOUND_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback
|
||||||
|
{
|
||||||
|
NSString *path = [self filesystemPathForURL:localURL];
|
||||||
|
CDVPluginResult *result;
|
||||||
|
NSFileManager* fileMgr = [[NSFileManager alloc] init];
|
||||||
|
|
||||||
|
NSError* __autoreleasing error = nil;
|
||||||
|
NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:path error:&error];
|
||||||
|
|
||||||
|
if (fileAttrs) {
|
||||||
|
|
||||||
|
// create dictionary of file info
|
||||||
|
NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
|
||||||
|
|
||||||
|
[fileInfo setObject:localURL.fullPath forKey:@"fullPath"];
|
||||||
|
[fileInfo setObject:[self mimeTypeForFileAtPath: path] forKey:@"type"];
|
||||||
|
[fileInfo setObject:[path lastPathComponent] forKey:@"name"];
|
||||||
|
|
||||||
|
// Ensure that directories (and other non-regular files) report size of 0
|
||||||
|
unsigned long long size = ([fileAttrs fileType] == NSFileTypeRegular ? [fileAttrs fileSize] : 0);
|
||||||
|
[fileInfo setObject:[NSNumber numberWithUnsignedLongLong:size] forKey:@"size"];
|
||||||
|
|
||||||
|
NSDate* modDate = [fileAttrs fileModificationDate];
|
||||||
|
if (modDate) {
|
||||||
|
[fileInfo setObject:[NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000] forKey:@"lastModifiedDate"];
|
||||||
|
}
|
||||||
|
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// didn't get fileAttribs
|
||||||
|
CDVFileError errorCode = ABORT_ERR;
|
||||||
|
NSLog(@"error getting metadata: %@", [error localizedDescription]);
|
||||||
|
if ([error code] == NSFileNoSuchFileError || [error code] == NSFileReadNoSuchFileError) {
|
||||||
|
errorCode = NOT_FOUND_ERR;
|
||||||
|
}
|
||||||
|
// log [NSNumber numberWithDouble: theMessage] objCtype to see what it returns
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode];
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix errors that base on Alexsander Akers from http://stackoverflow.com/a/5998683/2613194
|
||||||
|
- (NSString*) mimeTypeForFileAtPath: (NSString *) path {
|
||||||
|
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[path pathExtension], NULL);
|
||||||
|
CFStringRef mimeType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
|
||||||
|
CFRelease(UTI);
|
||||||
|
|
||||||
|
if (!mimeType) {
|
||||||
|
return @"application/octet-stream";
|
||||||
|
}
|
||||||
|
return (__bridge NSString *)mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <CoreLocation/CoreLocation.h>
|
||||||
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
enum CDVLocationStatus {
|
||||||
|
PERMISSIONDENIED = 1,
|
||||||
|
POSITIONUNAVAILABLE,
|
||||||
|
TIMEOUT
|
||||||
|
};
|
||||||
|
typedef NSUInteger CDVLocationStatus;
|
||||||
|
|
||||||
|
// simple object to keep track of location information
|
||||||
|
@interface CDVLocationData : NSObject {
|
||||||
|
CDVLocationStatus locationStatus;
|
||||||
|
NSMutableArray* locationCallbacks;
|
||||||
|
NSMutableDictionary* watchCallbacks;
|
||||||
|
CLLocation* locationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@property (nonatomic, assign) CDVLocationStatus locationStatus;
|
||||||
|
@property (nonatomic, strong) CLLocation* locationInfo;
|
||||||
|
@property (nonatomic, strong) NSMutableArray* locationCallbacks;
|
||||||
|
@property (nonatomic, strong) NSMutableDictionary* watchCallbacks;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface CDVLocation : CDVPlugin <CLLocationManagerDelegate>{
|
||||||
|
@private BOOL __locationStarted;
|
||||||
|
@private BOOL __highAccuracyEnabled;
|
||||||
|
CDVLocationData* locationData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@property (nonatomic, strong) CLLocationManager* locationManager;
|
||||||
|
@property (nonatomic, strong) CDVLocationData* locationData;
|
||||||
|
|
||||||
|
- (void)getLocation:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)addWatch:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)clearWatch:(CDVInvokedUrlCommand*)command;
|
||||||
|
- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback;
|
||||||
|
- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message;
|
||||||
|
- (void)startLocation:(BOOL)enableHighAccuracy;
|
||||||
|
|
||||||
|
- (void)locationManager:(CLLocationManager*)manager
|
||||||
|
didUpdateToLocation:(CLLocation*)newLocation
|
||||||
|
fromLocation:(CLLocation*)oldLocation;
|
||||||
|
|
||||||
|
- (void)locationManager:(CLLocationManager*)manager
|
||||||
|
didFailWithError:(NSError*)error;
|
||||||
|
|
||||||
|
- (BOOL)isLocationServicesEnabled;
|
||||||
|
@end
|
@ -0,0 +1,374 @@
|
|||||||
|
/*
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "CDVLocation.h"
|
||||||
|
|
||||||
|
#pragma mark Constants
|
||||||
|
|
||||||
|
#define kPGLocationErrorDomain @"kPGLocationErrorDomain"
|
||||||
|
#define kPGLocationDesiredAccuracyKey @"desiredAccuracy"
|
||||||
|
#define kPGLocationForcePromptKey @"forcePrompt"
|
||||||
|
#define kPGLocationDistanceFilterKey @"distanceFilter"
|
||||||
|
#define kPGLocationFrequencyKey @"frequency"
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Categories
|
||||||
|
|
||||||
|
@implementation CDVLocationData
|
||||||
|
|
||||||
|
@synthesize locationStatus, locationInfo, locationCallbacks, watchCallbacks;
|
||||||
|
- (CDVLocationData*)init
|
||||||
|
{
|
||||||
|
self = (CDVLocationData*)[super init];
|
||||||
|
if (self) {
|
||||||
|
self.locationInfo = nil;
|
||||||
|
self.locationCallbacks = nil;
|
||||||
|
self.watchCallbacks = nil;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark CDVLocation
|
||||||
|
|
||||||
|
@implementation CDVLocation
|
||||||
|
|
||||||
|
@synthesize locationManager, locationData;
|
||||||
|
|
||||||
|
- (void)pluginInitialize
|
||||||
|
{
|
||||||
|
self.locationManager = [[CLLocationManager alloc] init];
|
||||||
|
self.locationManager.delegate = self; // Tells the location manager to send updates to this object
|
||||||
|
__locationStarted = NO;
|
||||||
|
__highAccuracyEnabled = NO;
|
||||||
|
self.locationData = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isAuthorized
|
||||||
|
{
|
||||||
|
BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
|
||||||
|
|
||||||
|
if (authorizationStatusClassPropertyAvailable) {
|
||||||
|
NSUInteger authStatus = [CLLocationManager authorizationStatus];
|
||||||
|
#ifdef __IPHONE_8_0
|
||||||
|
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { //iOS 8.0+
|
||||||
|
return (authStatus == kCLAuthorizationStatusAuthorizedWhenInUse) || (authStatus == kCLAuthorizationStatusAuthorizedAlways) || (authStatus == kCLAuthorizationStatusNotDetermined);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (authStatus == kCLAuthorizationStatusAuthorizedAlways) || (authStatus == kCLAuthorizationStatusNotDetermined);
|
||||||
|
}
|
||||||
|
|
||||||
|
// by default, assume YES (for iOS < 4.2)
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isLocationServicesEnabled
|
||||||
|
{
|
||||||
|
BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
|
||||||
|
BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x
|
||||||
|
|
||||||
|
if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x
|
||||||
|
return [CLLocationManager locationServicesEnabled];
|
||||||
|
} else {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startLocation:(BOOL)enableHighAccuracy
|
||||||
|
{
|
||||||
|
if (![self isLocationServicesEnabled]) {
|
||||||
|
[self returnLocationError:PERMISSIONDENIED withMessage:@"Location services are not enabled."];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (![self isAuthorized]) {
|
||||||
|
NSString* message = nil;
|
||||||
|
BOOL authStatusAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
|
||||||
|
if (authStatusAvailable) {
|
||||||
|
NSUInteger code = [CLLocationManager authorizationStatus];
|
||||||
|
if (code == kCLAuthorizationStatusNotDetermined) {
|
||||||
|
// could return POSITION_UNAVAILABLE but need to coordinate with other platforms
|
||||||
|
message = @"User undecided on application's use of location services.";
|
||||||
|
} else if (code == kCLAuthorizationStatusRestricted) {
|
||||||
|
message = @"Application's use of location services is restricted.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PERMISSIONDENIED is only PositionError that makes sense when authorization denied
|
||||||
|
[self returnLocationError:PERMISSIONDENIED withMessage:message];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __IPHONE_8_0
|
||||||
|
NSUInteger code = [CLLocationManager authorizationStatus];
|
||||||
|
if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) { //iOS8+
|
||||||
|
__highAccuracyEnabled = enableHighAccuracy;
|
||||||
|
if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]){
|
||||||
|
[self.locationManager requestWhenInUseAuthorization];
|
||||||
|
} else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]) {
|
||||||
|
[self.locationManager requestAlwaysAuthorization];
|
||||||
|
} else {
|
||||||
|
NSLog(@"[Warning] No NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key is defined in the Info.plist file.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Tell the location manager to start notifying us of location updates. We
|
||||||
|
// first stop, and then start the updating to ensure we get at least one
|
||||||
|
// update, even if our location did not change.
|
||||||
|
[self.locationManager stopUpdatingLocation];
|
||||||
|
[self.locationManager startUpdatingLocation];
|
||||||
|
__locationStarted = YES;
|
||||||
|
if (enableHighAccuracy) {
|
||||||
|
__highAccuracyEnabled = YES;
|
||||||
|
// Set distance filter to 5 for a high accuracy. Setting it to "kCLDistanceFilterNone" could provide a
|
||||||
|
// higher accuracy, but it's also just spamming the callback with useless reports which drain the battery.
|
||||||
|
self.locationManager.distanceFilter = 5;
|
||||||
|
// Set desired accuracy to Best.
|
||||||
|
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
|
||||||
|
} else {
|
||||||
|
__highAccuracyEnabled = NO;
|
||||||
|
self.locationManager.distanceFilter = 10;
|
||||||
|
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_stopLocation
|
||||||
|
{
|
||||||
|
if (__locationStarted) {
|
||||||
|
if (![self isLocationServicesEnabled]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.locationManager stopUpdatingLocation];
|
||||||
|
__locationStarted = NO;
|
||||||
|
__highAccuracyEnabled = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)locationManager:(CLLocationManager*)manager
|
||||||
|
didUpdateToLocation:(CLLocation*)newLocation
|
||||||
|
fromLocation:(CLLocation*)oldLocation
|
||||||
|
{
|
||||||
|
CDVLocationData* cData = self.locationData;
|
||||||
|
|
||||||
|
cData.locationInfo = newLocation;
|
||||||
|
@synchronized (self.locationData.locationCallbacks) {
|
||||||
|
if (self.locationData.locationCallbacks.count > 0) {
|
||||||
|
for (NSString* callbackId in self.locationData.locationCallbacks) {
|
||||||
|
[self returnLocationInfo:callbackId andKeepCallback:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.locationData.locationCallbacks removeAllObjects];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (self.locationData.watchCallbacks.count > 0) {
|
||||||
|
for (NSString* timerId in self.locationData.watchCallbacks) {
|
||||||
|
[self returnLocationInfo:[self.locationData.watchCallbacks objectForKey:timerId] andKeepCallback:YES];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No callbacks waiting on us anymore, turn off listening.
|
||||||
|
[self _stopLocation];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)getLocation:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
[self.commandDelegate runInBackground:^{
|
||||||
|
NSString* callbackId = command.callbackId;
|
||||||
|
BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];
|
||||||
|
|
||||||
|
if ([self isLocationServicesEnabled] == NO) {
|
||||||
|
NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||||
|
[posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
|
||||||
|
[posError setObject:@"Location services are disabled." forKey:@"message"];
|
||||||
|
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||||
|
} else {
|
||||||
|
if (!self.locationData) {
|
||||||
|
self.locationData = [[CDVLocationData alloc] init];
|
||||||
|
}
|
||||||
|
CDVLocationData* lData = self.locationData;
|
||||||
|
@synchronized (self.locationData.locationCallbacks) {
|
||||||
|
if (!lData.locationCallbacks) {
|
||||||
|
lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
|
||||||
|
// add the callbackId into the array so we can call back when get data
|
||||||
|
@synchronized (self.locationData.locationCallbacks) {
|
||||||
|
if (callbackId != nil) {
|
||||||
|
[lData.locationCallbacks addObject:callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Tell the location manager to start notifying us of heading updates
|
||||||
|
[self startLocation:enableHighAccuracy];
|
||||||
|
} else {
|
||||||
|
[self returnLocationInfo:callbackId andKeepCallback:NO];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)addWatch:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
NSString* callbackId = command.callbackId;
|
||||||
|
NSString* timerId = [command argumentAtIndex:0];
|
||||||
|
BOOL enableHighAccuracy = [[command argumentAtIndex:1] boolValue];
|
||||||
|
|
||||||
|
if (!self.locationData) {
|
||||||
|
self.locationData = [[CDVLocationData alloc] init];
|
||||||
|
}
|
||||||
|
CDVLocationData* lData = self.locationData;
|
||||||
|
|
||||||
|
if (!lData.watchCallbacks) {
|
||||||
|
lData.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the callbackId into the dictionary so we can call back whenever get data
|
||||||
|
[lData.watchCallbacks setObject:callbackId forKey:timerId];
|
||||||
|
|
||||||
|
if ([self isLocationServicesEnabled] == NO) {
|
||||||
|
NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||||
|
[posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
|
||||||
|
[posError setObject:@"Location services are disabled." forKey:@"message"];
|
||||||
|
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||||
|
} else {
|
||||||
|
if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
|
||||||
|
// Tell the location manager to start notifying us of location updates
|
||||||
|
[self startLocation:enableHighAccuracy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)clearWatch:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
NSString* timerId = [command argumentAtIndex:0];
|
||||||
|
|
||||||
|
if (self.locationData && self.locationData.watchCallbacks && [self.locationData.watchCallbacks objectForKey:timerId]) {
|
||||||
|
[self.locationData.watchCallbacks removeObjectForKey:timerId];
|
||||||
|
if([self.locationData.watchCallbacks count] == 0) {
|
||||||
|
[self _stopLocation];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)stopLocation:(CDVInvokedUrlCommand*)command
|
||||||
|
{
|
||||||
|
[self _stopLocation];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback
|
||||||
|
{
|
||||||
|
CDVPluginResult* result = nil;
|
||||||
|
CDVLocationData* lData = self.locationData;
|
||||||
|
|
||||||
|
if (lData && !lData.locationInfo) {
|
||||||
|
// return error
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:POSITIONUNAVAILABLE];
|
||||||
|
} else if (lData && lData.locationInfo) {
|
||||||
|
CLLocation* lInfo = lData.locationInfo;
|
||||||
|
NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:8];
|
||||||
|
NSNumber* timestamp = [NSNumber numberWithDouble:([lInfo.timestamp timeIntervalSince1970] * 1000)];
|
||||||
|
[returnInfo setObject:timestamp forKey:@"timestamp"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.speed] forKey:@"velocity"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.verticalAccuracy] forKey:@"altitudeAccuracy"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.horizontalAccuracy] forKey:@"accuracy"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.course] forKey:@"heading"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.altitude] forKey:@"altitude"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.latitude] forKey:@"latitude"];
|
||||||
|
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.longitude] forKey:@"longitude"];
|
||||||
|
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
|
||||||
|
[result setKeepCallbackAsBool:keepCallback];
|
||||||
|
}
|
||||||
|
if (result) {
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message
|
||||||
|
{
|
||||||
|
NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||||
|
|
||||||
|
[posError setObject:[NSNumber numberWithUnsignedInteger:errorCode] forKey:@"code"];
|
||||||
|
[posError setObject:message ? message:@"" forKey:@"message"];
|
||||||
|
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
|
||||||
|
|
||||||
|
|
||||||
|
@synchronized (self.locationData.locationCallbacks) {
|
||||||
|
for (NSString* callbackId in self.locationData.locationCallbacks) {
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.locationData.locationCallbacks removeAllObjects];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NSString* callbackId in self.locationData.watchCallbacks) {
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
|
||||||
|
{
|
||||||
|
NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]);
|
||||||
|
|
||||||
|
CDVLocationData* lData = self.locationData;
|
||||||
|
if (lData && __locationStarted) {
|
||||||
|
// TODO: probably have to once over the various error codes and return one of:
|
||||||
|
// PositionError.PERMISSION_DENIED = 1;
|
||||||
|
// PositionError.POSITION_UNAVAILABLE = 2;
|
||||||
|
// PositionError.TIMEOUT = 3;
|
||||||
|
NSUInteger positionError = POSITIONUNAVAILABLE;
|
||||||
|
if (error.code == kCLErrorDenied) {
|
||||||
|
positionError = PERMISSIONDENIED;
|
||||||
|
}
|
||||||
|
[self returnLocationError:positionError withMessage:[error localizedDescription]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.code != kCLErrorLocationUnknown) {
|
||||||
|
[self.locationManager stopUpdatingLocation];
|
||||||
|
__locationStarted = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//iOS8+
|
||||||
|
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
|
||||||
|
{
|
||||||
|
if(!__locationStarted){
|
||||||
|
[self startLocation:__highAccuracyEnabled];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
self.locationManager.delegate = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onReset
|
||||||
|
{
|
||||||
|
[self _stopLocation];
|
||||||
|
[self.locationManager stopUpdatingHeading];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|