├── JS_OC_Cordova
├── JS_OC_Cordova.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ ├── haley.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── harvey.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── haley.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── harvey.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── JS_OC_Cordova.xcscheme
│ │ └── xcschememanagement.plist
└── JS_OC_Cordova
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── CordovaLib
│ ├── Private
│ │ ├── CDVDebug.h
│ │ ├── CDVJSON_private.h
│ │ ├── CDVJSON_private.m
│ │ ├── CDVPlugin+Private.h
│ │ └── Plugins
│ │ │ ├── CDVGestureHandler
│ │ │ ├── CDVGestureHandler.h
│ │ │ └── CDVGestureHandler.m
│ │ │ ├── CDVHandleOpenURL
│ │ │ ├── CDVHandleOpenURL.h
│ │ │ └── CDVHandleOpenURL.m
│ │ │ ├── CDVIntentAndNavigationFilter
│ │ │ ├── CDVIntentAndNavigationFilter.h
│ │ │ └── CDVIntentAndNavigationFilter.m
│ │ │ ├── CDVLocalStorage
│ │ │ ├── CDVLocalStorage.h
│ │ │ └── CDVLocalStorage.m
│ │ │ └── CDVUIWebViewEngine
│ │ │ ├── CDVUIWebViewDelegate.h
│ │ │ ├── CDVUIWebViewDelegate.m
│ │ │ ├── CDVUIWebViewEngine.h
│ │ │ ├── CDVUIWebViewEngine.m
│ │ │ ├── CDVUIWebViewNavigationDelegate.h
│ │ │ └── CDVUIWebViewNavigationDelegate.m
│ ├── Public
│ │ ├── CDV.h
│ │ ├── CDVAppDelegate.h
│ │ ├── CDVAppDelegate.m
│ │ ├── CDVAvailability.h
│ │ ├── CDVAvailabilityDeprecated.h
│ │ ├── CDVCommandDelegate.h
│ │ ├── CDVCommandDelegateImpl.h
│ │ ├── CDVCommandDelegateImpl.m
│ │ ├── CDVCommandQueue.h
│ │ ├── CDVCommandQueue.m
│ │ ├── CDVConfigParser.h
│ │ ├── CDVConfigParser.m
│ │ ├── CDVInvokedUrlCommand.h
│ │ ├── CDVInvokedUrlCommand.m
│ │ ├── CDVPlugin+Resources.h
│ │ ├── CDVPlugin+Resources.m
│ │ ├── CDVPlugin.h
│ │ ├── CDVPlugin.m
│ │ ├── CDVPluginResult.h
│ │ ├── CDVPluginResult.m
│ │ ├── CDVScreenOrientationDelegate.h
│ │ ├── CDVTimer.h
│ │ ├── CDVTimer.m
│ │ ├── CDVURLProtocol.h
│ │ ├── CDVURLProtocol.m
│ │ ├── CDVUserAgentUtil.h
│ │ ├── CDVUserAgentUtil.m
│ │ ├── CDVViewController.h
│ │ ├── CDVViewController.m
│ │ ├── CDVWebViewEngineProtocol.h
│ │ ├── CDVWhitelist.h
│ │ ├── CDVWhitelist.m
│ │ ├── NSDictionary+CordovaPreferences.h
│ │ ├── NSDictionary+CordovaPreferences.m
│ │ ├── NSMutableArray+QueueAdditions.h
│ │ └── NSMutableArray+QueueAdditions.m
│ └── config.xml
│ ├── HLAudioPlayer.h
│ ├── HLAudioPlayer.m
│ ├── Info.plist
│ ├── Plugins
│ ├── HaleyPlugin.h
│ └── HaleyPlugin.m
│ ├── PrefixHeader.pch
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── main.m
│ ├── shake_sound_male.wav
│ └── www
│ ├── cordova.js
│ └── index.html
├── JS_OC_JavaScriptCore
├── JS_OC_JavaScriptCore.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ ├── haley.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── harvey.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── haley.xcuserdatad
│ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── harvey.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── JS_OC_JavaScriptCore.xcscheme
│ │ └── xcschememanagement.plist
└── JS_OC_JavaScriptCore
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── LaunchScreen.storyboard
│ ├── Info.plist
│ ├── MainViewController.h
│ ├── MainViewController.m
│ ├── MainViewController.xib
│ ├── WebViewController.h
│ ├── WebViewController.m
│ ├── index.html
│ └── main.m
├── JS_OC_MessageHandler
├── JS_OC_MessageHandler.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ ├── haley.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── harvey.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── haley.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── harvey.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── JS_OC_MessageHandler.xcscheme
│ │ └── xcschememanagement.plist
└── JS_OC_MessageHandler
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── LaunchScreen.storyboard
│ ├── HLAudioPlayer.h
│ ├── HLAudioPlayer.m
│ ├── Info.plist
│ ├── MainViewController.h
│ ├── MainViewController.m
│ ├── MainViewController.xib
│ ├── WKWebViewController.h
│ ├── WKWebViewController.m
│ ├── index.html
│ ├── main.m
│ └── shake_sound_male.wav
├── JS_OC_URL
├── JS_OC_URL.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ ├── haley.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── harvey.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── haley.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── harvey.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── JS_OC_URL.xcscheme
│ │ └── xcschememanagement.plist
└── JS_OC_URL
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── LaunchScreen.storyboard
│ ├── Info.plist
│ ├── MainViewController.h
│ ├── MainViewController.m
│ ├── MainViewController.xib
│ ├── WKWebViewController.h
│ ├── WKWebViewController.m
│ ├── WebViewController.h
│ ├── WebViewController.m
│ ├── index.html
│ └── main.m
├── JS_OC_WebViewJavascriptBridge
├── JS_OC_WebViewJavascriptBridge.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── harvey.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── harvey.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── JS_OC_WebViewJavascriptBridge.xcscheme
│ │ └── xcschememanagement.plist
└── JS_OC_WebViewJavascriptBridge
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── LaunchScreen.storyboard
│ ├── Info.plist
│ ├── MainViewController.h
│ ├── MainViewController.m
│ ├── MainViewController.xib
│ ├── WKWebViewController.h
│ ├── WKWebViewController.m
│ ├── WebViewController.h
│ ├── WebViewController.m
│ ├── WebViewJavascriptBridge
│ ├── WKWebViewJavascriptBridge.h
│ ├── WKWebViewJavascriptBridge.m
│ ├── WebViewJavascriptBridge.h
│ ├── WebViewJavascriptBridge.m
│ ├── WebViewJavascriptBridgeBase.h
│ ├── WebViewJavascriptBridgeBase.m
│ ├── WebViewJavascriptBridge_JS.h
│ └── WebViewJavascriptBridge_JS.m
│ ├── index.html
│ └── main.m
├── JS_OC_summary
├── JS_OC.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ ├── Harvey.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── haley.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── Harvey.xcuserdatad
│ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ │ ├── JS_OC.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── haley.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── JS_OC
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── First.html
│ ├── FirstViewController.h
│ ├── FirstViewController.m
│ ├── Info.plist
│ ├── Second.html
│ ├── SeondViewController.h
│ ├── SeondViewController.m
│ └── main.m
├── Simulator Screen 11.png
├── Simulator Screen 12.png
├── Simulator Screen 21.png
└── Simulator Screen 22.png
└── README.md
/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/xcuserdata/haley.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_Cordova.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/xcuserdata/harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_Cordova.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B954131F1D9BB9B600600D09
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JS_OC_Cordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JS_OC_Cordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/CDVDebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #ifdef DEBUG
21 | #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
22 | #else
23 | #define DLog(...)
24 | #endif
25 | #define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
26 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/CDVJSON_private.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | @interface NSArray (CDVJSONSerializingPrivate)
21 | - (NSString*)cdv_JSONString;
22 | @end
23 |
24 | @interface NSDictionary (CDVJSONSerializingPrivate)
25 | - (NSString*)cdv_JSONString;
26 | @end
27 |
28 | @interface NSString (CDVJSONSerializingPrivate)
29 | - (id)cdv_JSONObject;
30 | - (id)cdv_JSONFragment;
31 | @end
32 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/CDVJSON_private.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVJSON_private.h"
21 | #import
22 |
23 | @implementation NSArray (CDVJSONSerializingPrivate)
24 |
25 | - (NSString*)cdv_JSONString
26 | {
27 | NSError* error = nil;
28 | NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
29 | options:0
30 | error:&error];
31 |
32 | if (error != nil) {
33 | NSLog(@"NSArray JSONString error: %@", [error localizedDescription]);
34 | return nil;
35 | } else {
36 | return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
37 | }
38 | }
39 |
40 | @end
41 |
42 | @implementation NSDictionary (CDVJSONSerializingPrivate)
43 |
44 | - (NSString*)cdv_JSONString
45 | {
46 | NSError* error = nil;
47 | NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
48 | options:NSJSONWritingPrettyPrinted
49 | error:&error];
50 |
51 | if (error != nil) {
52 | NSLog(@"NSDictionary JSONString error: %@", [error localizedDescription]);
53 | return nil;
54 | } else {
55 | return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
56 | }
57 | }
58 |
59 | @end
60 |
61 | @implementation NSString (CDVJSONSerializingPrivate)
62 |
63 | - (id)cdv_JSONObject
64 | {
65 | NSError* error = nil;
66 | id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
67 | options:NSJSONReadingMutableContainers
68 | error:&error];
69 |
70 | if (error != nil) {
71 | NSLog(@"NSString JSONObject error: %@", [error localizedDescription]);
72 | }
73 |
74 | return object;
75 | }
76 |
77 | - (id)cdv_JSONFragment
78 | {
79 | NSError* error = nil;
80 | id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
81 | options:NSJSONReadingAllowFragments
82 | error:&error];
83 |
84 | if (error != nil) {
85 | NSLog(@"NSString JSONObject error: %@", [error localizedDescription]);
86 | }
87 |
88 | return object;
89 | }
90 |
91 | @end
92 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/CDVPlugin+Private.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | @interface CDVPlugin (Private)
21 |
22 | - (instancetype)initWithWebViewEngine:(id )theWebViewEngine;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/Plugins/CDVGestureHandler/CDVGestureHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVPlugin.h"
21 |
22 | @interface CDVGestureHandler : CDVPlugin
23 |
24 | @property (nonatomic, strong) UILongPressGestureRecognizer* lpgr;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/Plugins/CDVGestureHandler/CDVGestureHandler.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVGestureHandler.h"
21 |
22 | @implementation CDVGestureHandler
23 |
24 | - (void)pluginInitialize
25 | {
26 | [self applyLongPressFix];
27 | }
28 |
29 | - (void)applyLongPressFix
30 | {
31 | // You can't suppress 3D Touch and still have regular longpress,
32 | // so if this is false, let's not consider the 3D Touch setting at all.
33 | if (![self.commandDelegate.settings objectForKey:@"suppresseslongpressgesture"] ||
34 | ![[self.commandDelegate.settings objectForKey:@"suppresseslongpressgesture"] boolValue]) {
35 | return;
36 | }
37 |
38 | self.lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)];
39 | self.lpgr.minimumPressDuration = 0.45f;
40 | self.lpgr.allowableMovement = 100.0f;
41 |
42 | // 0.45 is ok for 'regular longpress', 0.05-0.08 is required for '3D Touch longpress',
43 | // but since this will also kill onclick handlers (not ontouchend) it's optional.
44 | if ([self.commandDelegate.settings objectForKey:@"suppresses3dtouchgesture"] &&
45 | [[self.commandDelegate.settings objectForKey:@"suppresses3dtouchgesture"] boolValue]) {
46 | self.lpgr.minimumPressDuration = 0.05f;
47 | }
48 |
49 | NSArray *views = self.webView.subviews;
50 | if (views.count == 0) {
51 | NSLog(@"No webview subviews found, not applying the longpress fix.");
52 | return;
53 | }
54 | for (int i=0; i
30 |
31 | + (CDVIntentAndNavigationFilterValue) filterUrl:(NSURL*)url intentsWhitelist:(CDVWhitelist*)intentsWhitelist navigationsWhitelist:(CDVWhitelist*)navigationsWhitelist;
32 | + (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue;
33 | + (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType;
34 | @end
35 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/Plugins/CDVLocalStorage/CDVLocalStorage.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVPlugin.h"
21 |
22 | #define kCDVLocalStorageErrorDomain @"kCDVLocalStorageErrorDomain"
23 | #define kCDVLocalStorageFileOperationError 1
24 |
25 | @interface CDVLocalStorage : CDVPlugin
26 |
27 | @property (nonatomic, readonly, strong) NSMutableArray* backupInfo;
28 |
29 | - (BOOL)shouldBackup;
30 | - (BOOL)shouldRestore;
31 | - (void)backup:(CDVInvokedUrlCommand*)command;
32 | - (void)restore:(CDVInvokedUrlCommand*)command;
33 |
34 | + (void)__fixupDatabaseLocationsWithBackupType:(NSString*)backupType;
35 | // Visible for testing.
36 | + (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
37 | bundlePath:(NSString*)bundlePath
38 | fileManager:(NSFileManager*)fileManager;
39 | @end
40 |
41 | @interface CDVBackupInfo : NSObject
42 |
43 | @property (nonatomic, copy) NSString* original;
44 | @property (nonatomic, copy) NSString* backup;
45 | @property (nonatomic, copy) NSString* label;
46 |
47 | - (BOOL)shouldBackup;
48 | - (BOOL)shouldRestore;
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVAvailability.h"
22 |
23 | /**
24 | * Distinguishes top-level navigations from sub-frame navigations.
25 | * shouldStartLoadWithRequest is called for every request, but didStartLoad
26 | * and didFinishLoad is called only for top-level navigations.
27 | * Relevant bug: CB-2389
28 | */
29 | @interface CDVUIWebViewDelegate : NSObject {
30 | __weak NSObject * _delegate;
31 | NSInteger _loadCount;
32 | NSInteger _state;
33 | NSInteger _curLoadToken;
34 | NSInteger _loadStartPollCount;
35 | }
36 |
37 | - (id)initWithDelegate:(NSObject *)delegate;
38 |
39 | - (BOOL)request:(NSURLRequest*)newRequest isEqualToRequestAfterStrippingFragments:(NSURLRequest*)originalRequest;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVPlugin.h"
21 | #import "CDVWebViewEngineProtocol.h"
22 |
23 | @interface CDVUIWebViewEngine : CDVPlugin
24 |
25 | @property (nonatomic, strong, readonly) id uiWebViewDelegate;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVUIWebViewEngine.h"
22 |
23 | @interface CDVUIWebViewNavigationDelegate : NSObject
24 |
25 | @property (nonatomic, weak) CDVPlugin* enginePlugin;
26 |
27 | - (instancetype)initWithEnginePlugin:(CDVPlugin*)enginePlugin;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDV.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVAvailability.h"
21 | #import "CDVAvailabilityDeprecated.h"
22 | #import "CDVAppDelegate.h"
23 | #import "CDVPlugin.h"
24 | #import "CDVPluginResult.h"
25 | #import "CDVViewController.h"
26 | #import "CDVCommandDelegate.h"
27 | #import "CDVURLProtocol.h"
28 | #import "CDVInvokedUrlCommand.h"
29 | #import "CDVWhitelist.h"
30 | #import "CDVScreenOrientationDelegate.h"
31 | #import "CDVTimer.h"
32 | #import "CDVUserAgentUtil.h"
33 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVAppDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVViewController.h"
22 |
23 | @interface CDVAppDelegate : NSObject {}
24 |
25 | @property (nonatomic, strong) IBOutlet UIWindow* window;
26 | @property (nonatomic, strong) IBOutlet CDVViewController* viewController;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVAvailability.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVAvailabilityDeprecated.h"
21 |
22 | #define __CORDOVA_IOS__
23 |
24 | #define __CORDOVA_0_9_6 906
25 | #define __CORDOVA_1_0_0 10000
26 | #define __CORDOVA_1_1_0 10100
27 | #define __CORDOVA_1_2_0 10200
28 | #define __CORDOVA_1_3_0 10300
29 | #define __CORDOVA_1_4_0 10400
30 | #define __CORDOVA_1_4_1 10401
31 | #define __CORDOVA_1_5_0 10500
32 | #define __CORDOVA_1_6_0 10600
33 | #define __CORDOVA_1_6_1 10601
34 | #define __CORDOVA_1_7_0 10700
35 | #define __CORDOVA_1_8_0 10800
36 | #define __CORDOVA_1_8_1 10801
37 | #define __CORDOVA_1_9_0 10900
38 | #define __CORDOVA_2_0_0 20000
39 | #define __CORDOVA_2_1_0 20100
40 | #define __CORDOVA_2_2_0 20200
41 | #define __CORDOVA_2_3_0 20300
42 | #define __CORDOVA_2_4_0 20400
43 | #define __CORDOVA_2_5_0 20500
44 | #define __CORDOVA_2_6_0 20600
45 | #define __CORDOVA_2_7_0 20700
46 | #define __CORDOVA_2_8_0 20800
47 | #define __CORDOVA_2_9_0 20900
48 | #define __CORDOVA_3_0_0 30000
49 | #define __CORDOVA_3_1_0 30100
50 | #define __CORDOVA_3_2_0 30200
51 | #define __CORDOVA_3_3_0 30300
52 | #define __CORDOVA_3_4_0 30400
53 | #define __CORDOVA_3_4_1 30401
54 | #define __CORDOVA_3_5_0 30500
55 | #define __CORDOVA_3_6_0 30600
56 | #define __CORDOVA_3_7_0 30700
57 | #define __CORDOVA_3_8_0 30800
58 | #define __CORDOVA_3_9_0 30900
59 | #define __CORDOVA_3_9_1 30901
60 | #define __CORDOVA_3_9_2 30902
61 | #define __CORDOVA_4_0_0 40000
62 | #define __CORDOVA_4_0_1 40001
63 | #define __CORDOVA_4_1_0 40100
64 | #define __CORDOVA_4_1_1 40101
65 | #define __CORDOVA_4_2_0 40200
66 | #define __CORDOVA_4_2_1 40201
67 | /* coho:next-version,insert-before */
68 | #define __CORDOVA_NA 99999 /* not available */
69 |
70 | /*
71 | #if CORDOVA_VERSION_MIN_REQUIRED >= __CORDOVA_4_0_0
72 | // do something when its at least 4.0.0
73 | #else
74 | // do something else (non 4.0.0)
75 | #endif
76 | */
77 | #ifndef CORDOVA_VERSION_MIN_REQUIRED
78 | /* coho:next-version-min-required,replace-after */
79 | #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_4_2_1
80 | #endif
81 |
82 | /*
83 | Returns YES if it is at least version specified as NSString(X)
84 | Usage:
85 | if (IsAtLeastiOSVersion(@"5.1")) {
86 | // do something for iOS 5.1 or greater
87 | }
88 | */
89 | #define IsAtLeastiOSVersion(X) ([[[UIDevice currentDevice] systemVersion] compare:X options:NSNumericSearch] != NSOrderedAscending)
90 |
91 | /* Return the string version of the decimal version */
92 | #define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
93 | (CORDOVA_VERSION_MIN_REQUIRED / 10000), \
94 | (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
95 | (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
96 |
97 | // Enable this to log all exec() calls.
98 | #define CDV_ENABLE_EXEC_LOGGING 0
99 | #if CDV_ENABLE_EXEC_LOGGING
100 | #define CDV_EXEC_LOG NSLog
101 | #else
102 | #define CDV_EXEC_LOG(...) do { \
103 | } while (NO)
104 | #endif
105 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVAvailabilityDeprecated.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | #ifdef __clang__
23 | #define CDV_DEPRECATED(version, msg) __attribute__((deprecated("Deprecated in Cordova " #version ". " msg)))
24 | #else
25 | #define CDV_DEPRECATED(version, msg) __attribute__((deprecated()))
26 | #endif
27 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVCommandDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVAvailability.h"
21 | #import "CDVInvokedUrlCommand.h"
22 |
23 | @class CDVPlugin;
24 | @class CDVPluginResult;
25 | @class CDVWhitelist;
26 |
27 | typedef NSURL* (^ UrlTransformerBlock)(NSURL*);
28 |
29 | @protocol CDVCommandDelegate
30 |
31 | @property (nonatomic, readonly) NSDictionary* settings;
32 | @property (nonatomic, copy) UrlTransformerBlock urlTransformer;
33 |
34 | - (NSString*)pathForResource:(NSString*)resourcepath;
35 | - (id)getCommandInstance:(NSString*)pluginName;
36 |
37 | // Sends a plugin result to the JS. This is thread-safe.
38 | - (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId;
39 | // Evaluates the given JS. This is thread-safe.
40 | - (void)evalJs:(NSString*)js;
41 | // Can be used to evaluate JS right away instead of scheduling it on the run-loop.
42 | // This is required for dispatch resign and pause events, but should not be used
43 | // without reason. Without the run-loop delay, alerts used in JS callbacks may result
44 | // in dead-lock. This method must be called from the UI thread.
45 | - (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
46 | // Runs the given block on a background thread using a shared thread-pool.
47 | - (void)runInBackground:(void (^)())block;
48 | // Returns the User-Agent of the associated UIWebView.
49 | - (NSString*)userAgent;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVCommandDelegateImpl.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVCommandDelegate.h"
22 |
23 | @class CDVViewController;
24 | @class CDVCommandQueue;
25 |
26 | @interface CDVCommandDelegateImpl : NSObject {
27 | @private
28 | __weak CDVViewController* _viewController;
29 | NSRegularExpression* _callbackIdPattern;
30 | @protected
31 | __weak CDVCommandQueue* _commandQueue;
32 | BOOL _delayResponses;
33 | }
34 | - (id)initWithViewController:(CDVViewController*)viewController;
35 | - (void)flushCommandQueueWithDelayedJs;
36 | @end
37 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVCommandQueue.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | @class CDVInvokedUrlCommand;
23 | @class CDVViewController;
24 |
25 | @interface CDVCommandQueue : NSObject
26 |
27 | @property (nonatomic, readonly) BOOL currentlyExecuting;
28 |
29 | - (id)initWithViewController:(CDVViewController*)viewController;
30 | - (void)dispose;
31 |
32 | - (void)resetRequestId;
33 | - (void)enqueueCommandBatch:(NSString*)batchJSON;
34 |
35 | - (void)fetchCommandsFromJs;
36 | - (void)executePending;
37 | - (BOOL)execute:(CDVInvokedUrlCommand*)command;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVConfigParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | @interface CDVConfigParser : NSObject
21 | {
22 | NSString* featureName;
23 | }
24 |
25 | @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
26 | @property (nonatomic, readonly, strong) NSMutableDictionary* settings;
27 | @property (nonatomic, readonly, strong) NSMutableArray* startupPluginNames;
28 | @property (nonatomic, readonly, strong) NSString* startPage;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVConfigParser.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVConfigParser.h"
21 |
22 | @interface CDVConfigParser ()
23 |
24 | @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict;
25 | @property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
26 | @property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
27 | @property (nonatomic, readwrite, strong) NSString* startPage;
28 |
29 | @end
30 |
31 | @implementation CDVConfigParser
32 |
33 | @synthesize pluginsDict, settings, startPage, startupPluginNames;
34 |
35 | - (id)init
36 | {
37 | self = [super init];
38 | if (self != nil) {
39 | self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30];
40 | self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
41 | self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
42 | featureName = nil;
43 | }
44 | return self;
45 | }
46 |
47 | - (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
48 | {
49 | if ([elementName isEqualToString:@"preference"]) {
50 | settings[[attributeDict[@"name"] lowercaseString]] = attributeDict[@"value"];
51 | } else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with correct parameter set
52 | featureName = [attributeDict[@"name"] lowercaseString];
53 | } else if ((featureName != nil) && [elementName isEqualToString:@"param"]) {
54 | NSString* paramName = [attributeDict[@"name"] lowercaseString];
55 | id value = attributeDict[@"value"];
56 | if ([paramName isEqualToString:@"ios-package"]) {
57 | pluginsDict[featureName] = value;
58 | }
59 | BOOL paramIsOnload = ([paramName isEqualToString:@"onload"] && [@"true" isEqualToString : value]);
60 | BOOL attribIsOnload = [@"true" isEqualToString :[attributeDict[@"onload"] lowercaseString]];
61 | if (paramIsOnload || attribIsOnload) {
62 | [self.startupPluginNames addObject:featureName];
63 | }
64 | } else if ([elementName isEqualToString:@"content"]) {
65 | self.startPage = attributeDict[@"src"];
66 | }
67 | }
68 |
69 | - (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName
70 | {
71 | if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release
72 | featureName = nil;
73 | }
74 | }
75 |
76 | - (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
77 | {
78 | NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser columnNumber]);
79 | }
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVInvokedUrlCommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | @interface CDVInvokedUrlCommand : NSObject {
23 | NSString* _callbackId;
24 | NSString* _className;
25 | NSString* _methodName;
26 | NSArray* _arguments;
27 | }
28 |
29 | @property (nonatomic, readonly) NSArray* arguments;
30 | @property (nonatomic, readonly) NSString* callbackId;
31 | @property (nonatomic, readonly) NSString* className;
32 | @property (nonatomic, readonly) NSString* methodName;
33 |
34 | + (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry;
35 |
36 | - (id)initWithArguments:(NSArray*)arguments
37 | callbackId:(NSString*)callbackId
38 | className:(NSString*)className
39 | methodName:(NSString*)methodName;
40 |
41 | - (id)initFromJson:(NSArray*)jsonEntry;
42 |
43 | // Returns the argument at the given index.
44 | // If index >= the number of arguments, returns nil.
45 | // If the argument at the given index is NSNull, returns nil.
46 | - (id)argumentAtIndex:(NSUInteger)index;
47 | // Same as above, but returns defaultValue instead of nil.
48 | - (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue;
49 | // Same as above, but returns defaultValue instead of nil, and if the argument is not of the expected class, returns defaultValue
50 | - (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass;
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVPlugin+Resources.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVPlugin.h"
22 |
23 | @interface CDVPlugin (CDVPluginResources)
24 |
25 | /*
26 | This will return the localized string for a key in a .bundle that is named the same as your class
27 | For example, if your plugin class was called Foo, and you have a Spanish localized strings file, it will
28 | try to load the desired key from Foo.bundle/es.lproj/Localizable.strings
29 | */
30 | - (NSString*)pluginLocalizedString:(NSString*)key;
31 |
32 | /*
33 | This will return the image for a name in a .bundle that is named the same as your class
34 | For example, if your plugin class was called Foo, and you have an image called "bar",
35 | it will try to load the image from Foo.bundle/bar.png (and appropriately named retina versions)
36 | */
37 | - (UIImage*)pluginImageResource:(NSString*)name;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVPlugin+Resources.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVPlugin+Resources.h"
21 |
22 | @implementation CDVPlugin (CDVPluginResources)
23 |
24 | - (NSString*)pluginLocalizedString:(NSString*)key
25 | {
26 | NSBundle* bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:NSStringFromClass([self class]) ofType:@"bundle"]];
27 |
28 | return [bundle localizedStringForKey:(key) value:nil table:nil];
29 | }
30 |
31 | - (UIImage*)pluginImageResource:(NSString*)name
32 | {
33 | NSString* resourceIdentifier = [NSString stringWithFormat:@"%@.bundle/%@", NSStringFromClass([self class]), name];
34 |
35 | return [UIImage imageNamed:resourceIdentifier];
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVPlugin.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import
22 | #import "CDVPluginResult.h"
23 | #import "NSMutableArray+QueueAdditions.h"
24 | #import "CDVCommandDelegate.h"
25 | #import "CDVWebViewEngineProtocol.h"
26 |
27 | @interface UIView (org_apache_cordova_UIView_Extension)
28 |
29 | @property (nonatomic, weak) UIScrollView* scrollView;
30 |
31 | @end
32 |
33 | extern NSString* const CDVPageDidLoadNotification;
34 | extern NSString* const CDVPluginHandleOpenURLNotification;
35 | extern NSString* const CDVPluginResetNotification;
36 | extern NSString* const CDVLocalNotification;
37 | extern NSString* const CDVRemoteNotification;
38 | extern NSString* const CDVRemoteNotificationError;
39 | extern NSString* const CDVViewWillAppearNotification;
40 | extern NSString* const CDVViewDidAppearNotification;
41 | extern NSString* const CDVViewWillDisappearNotification;
42 | extern NSString* const CDVViewDidDisappearNotification;
43 | extern NSString* const CDVViewWillLayoutSubviewsNotification;
44 | extern NSString* const CDVViewDidLayoutSubviewsNotification;
45 | extern NSString* const CDVViewWillTransitionToSizeNotification;
46 |
47 | @interface CDVPlugin : NSObject {}
48 |
49 | @property (nonatomic, readonly, weak) UIView* webView;
50 | @property (nonatomic, readonly, weak) id webViewEngine;
51 |
52 | @property (nonatomic, weak) UIViewController* viewController;
53 | @property (nonatomic, weak) id commandDelegate;
54 |
55 | @property (readonly, assign) BOOL hasPendingOperation;
56 |
57 | - (void)pluginInitialize;
58 |
59 | - (void)handleOpenURL:(NSNotification*)notification;
60 | - (void)onAppTerminate;
61 | - (void)onMemoryWarning;
62 | - (void)onReset;
63 | - (void)dispose;
64 |
65 | /*
66 | // see initWithWebView implementation
67 | - (void) onPause {}
68 | - (void) onResume {}
69 | - (void) onOrientationWillChange {}
70 | - (void) onOrientationDidChange {}
71 | - (void)didReceiveLocalNotification:(NSNotification *)notification;
72 | */
73 |
74 | - (id)appDelegate;
75 |
76 | @end
77 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVPluginResult.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVAvailability.h"
22 |
23 | typedef enum {
24 | CDVCommandStatus_NO_RESULT = 0,
25 | CDVCommandStatus_OK,
26 | CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION,
27 | CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION,
28 | CDVCommandStatus_INSTANTIATION_EXCEPTION,
29 | CDVCommandStatus_MALFORMED_URL_EXCEPTION,
30 | CDVCommandStatus_IO_EXCEPTION,
31 | CDVCommandStatus_INVALID_ACTION,
32 | CDVCommandStatus_JSON_EXCEPTION,
33 | CDVCommandStatus_ERROR
34 | } CDVCommandStatus;
35 |
36 | @interface CDVPluginResult : NSObject {}
37 |
38 | @property (nonatomic, strong, readonly) NSNumber* status;
39 | @property (nonatomic, strong, readonly) id message;
40 | @property (nonatomic, strong) NSNumber* keepCallback;
41 | // This property can be used to scope the lifetime of another object. For example,
42 | // Use it to store the associated NSData when `message` is created using initWithBytesNoCopy.
43 | @property (nonatomic, strong) id associatedObject;
44 |
45 | - (CDVPluginResult*)init;
46 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal;
47 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage;
48 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage;
49 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage;
50 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSInteger:(NSInteger)theMessage;
51 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)theMessage;
52 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage;
53 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage;
54 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage;
55 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage;
56 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages;
57 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode;
58 |
59 | + (void)setVerbose:(BOOL)verbose;
60 | + (BOOL)isVerbose;
61 |
62 | - (void)setKeepCallbackAsBool:(BOOL)bKeepCallback;
63 |
64 | - (NSString*)argumentsAsJSON;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVScreenOrientationDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | @protocol CDVScreenOrientationDelegate
23 |
24 | - (NSUInteger)supportedInterfaceOrientations;
25 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
26 | - (BOOL)shouldAutorotate;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVTimer.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | @interface CDVTimer : NSObject
23 |
24 | + (void)start:(NSString*)name;
25 | + (void)stop:(NSString*)name;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVTimer.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "CDVTimer.h"
21 |
22 | #pragma mark CDVTimerItem
23 |
24 | @interface CDVTimerItem : NSObject
25 |
26 | @property (nonatomic, strong) NSString* name;
27 | @property (nonatomic, strong) NSDate* started;
28 | @property (nonatomic, strong) NSDate* ended;
29 |
30 | - (void)log;
31 |
32 | @end
33 |
34 | @implementation CDVTimerItem
35 |
36 | - (void)log
37 | {
38 | NSLog(@"[CDVTimer][%@] %fms", self.name, [self.ended timeIntervalSinceDate:self.started] * 1000.0);
39 | }
40 |
41 | @end
42 |
43 | #pragma mark CDVTimer
44 |
45 | @interface CDVTimer ()
46 |
47 | @property (nonatomic, strong) NSMutableDictionary* items;
48 |
49 | @end
50 |
51 | @implementation CDVTimer
52 |
53 | #pragma mark object methods
54 |
55 | - (id)init
56 | {
57 | if (self = [super init]) {
58 | self.items = [NSMutableDictionary dictionaryWithCapacity:6];
59 | }
60 |
61 | return self;
62 | }
63 |
64 | - (void)add:(NSString*)name
65 | {
66 | if ([self.items objectForKey:[name lowercaseString]] == nil) {
67 | CDVTimerItem* item = [CDVTimerItem new];
68 | item.name = name;
69 | item.started = [NSDate new];
70 | [self.items setObject:item forKey:[name lowercaseString]];
71 | } else {
72 | NSLog(@"Timer called '%@' already exists.", name);
73 | }
74 | }
75 |
76 | - (void)remove:(NSString*)name
77 | {
78 | CDVTimerItem* item = [self.items objectForKey:[name lowercaseString]];
79 |
80 | if (item != nil) {
81 | item.ended = [NSDate new];
82 | [item log];
83 | [self.items removeObjectForKey:[name lowercaseString]];
84 | } else {
85 | NSLog(@"Timer called '%@' does not exist.", name);
86 | }
87 | }
88 |
89 | - (void)removeAll
90 | {
91 | [self.items removeAllObjects];
92 | }
93 |
94 | #pragma mark class methods
95 |
96 | + (void)start:(NSString*)name
97 | {
98 | [[CDVTimer sharedInstance] add:name];
99 | }
100 |
101 | + (void)stop:(NSString*)name
102 | {
103 | [[CDVTimer sharedInstance] remove:name];
104 | }
105 |
106 | + (void)clearAll
107 | {
108 | [[CDVTimer sharedInstance] removeAll];
109 | }
110 |
111 | + (CDVTimer*)sharedInstance
112 | {
113 | static dispatch_once_t pred = 0;
114 | __strong static CDVTimer* _sharedObject = nil;
115 |
116 | dispatch_once(&pred, ^{
117 | _sharedObject = [[self alloc] init];
118 | });
119 |
120 | return _sharedObject;
121 | }
122 |
123 | @end
124 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVURLProtocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVAvailability.h"
22 |
23 | @class CDVViewController;
24 |
25 | @interface CDVURLProtocol : NSURLProtocol {}
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVUserAgentUtil.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | @interface CDVUserAgentUtil : NSObject
23 | + (NSString*)originalUserAgent;
24 | + (void)acquireLock:(void (^)(NSInteger lockToken))block;
25 | + (void)releaseLock:(NSInteger*)lockToken;
26 | + (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken;
27 | @end
28 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVViewController.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import
22 | #import "CDVAvailability.h"
23 | #import "CDVInvokedUrlCommand.h"
24 | #import "CDVCommandDelegate.h"
25 | #import "CDVCommandQueue.h"
26 | #import "CDVScreenOrientationDelegate.h"
27 | #import "CDVPlugin.h"
28 | #import "CDVWebViewEngineProtocol.h"
29 |
30 | @interface CDVViewController : UIViewController {
31 | @protected
32 | id _webViewEngine;
33 | @protected
34 | id _commandDelegate;
35 | @protected
36 | CDVCommandQueue* _commandQueue;
37 | NSString* _userAgent;
38 | }
39 |
40 | @property (nonatomic, readonly, weak) IBOutlet UIView* webView;
41 |
42 | @property (nonatomic, readonly, strong) NSMutableDictionary* pluginObjects;
43 | @property (nonatomic, readonly, strong) NSDictionary* pluginsMap;
44 | @property (nonatomic, readonly, strong) NSMutableDictionary* settings;
45 | @property (nonatomic, readonly, strong) NSXMLParser* configParser;
46 |
47 | @property (nonatomic, readwrite, copy) NSString* configFile;
48 | @property (nonatomic, readwrite, copy) NSString* wwwFolderName;
49 | @property (nonatomic, readwrite, copy) NSString* startPage;
50 | @property (nonatomic, readonly, strong) CDVCommandQueue* commandQueue;
51 | @property (nonatomic, readonly, strong) id webViewEngine;
52 | @property (nonatomic, readonly, strong) id commandDelegate;
53 |
54 | /**
55 | The complete user agent that Cordova will use when sending web requests.
56 | */
57 | @property (nonatomic, readonly) NSString* userAgent;
58 |
59 | /**
60 | The base user agent data that Cordova will use to build its user agent. If this
61 | property isn't set, Cordova will use the standard web view user agent as its
62 | base.
63 | */
64 | @property (nonatomic, readwrite, copy) NSString* baseUserAgent;
65 |
66 | /**
67 | Takes/Gives an array of UIInterfaceOrientation (int) objects
68 | ex. UIInterfaceOrientationPortrait
69 | */
70 | @property (nonatomic, readwrite, strong) NSArray* supportedOrientations;
71 |
72 | /**
73 | The address of the lock token used for controlling access to setting the user-agent
74 | */
75 | @property (nonatomic, readonly) NSInteger* userAgentLockToken;
76 |
77 | - (UIView*)newCordovaViewWithFrame:(CGRect)bounds;
78 |
79 | - (NSString*)appURLScheme;
80 | - (NSURL*)errorURL;
81 |
82 | - (NSArray*)parseInterfaceOrientations:(NSArray*)orientations;
83 | - (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation;
84 |
85 | - (id)getCommandInstance:(NSString*)pluginName;
86 | - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className;
87 | - (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
88 |
89 | - (void)parseSettingsWithParser:(NSObject *)delegate;
90 |
91 | @end
92 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVWebViewEngineProtocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | #define kCDVWebViewEngineScriptMessageHandlers @"kCDVWebViewEngineScriptMessageHandlers"
23 | #define kCDVWebViewEngineUIWebViewDelegate @"kCDVWebViewEngineUIWebViewDelegate"
24 | #define kCDVWebViewEngineWKNavigationDelegate @"kCDVWebViewEngineWKNavigationDelegate"
25 | #define kCDVWebViewEngineWKUIDelegate @"kCDVWebViewEngineWKUIDelegate"
26 | #define kCDVWebViewEngineWebViewPreferences @"kCDVWebViewEngineWebViewPreferences"
27 |
28 | @protocol CDVWebViewEngineProtocol
29 |
30 | @property (nonatomic, strong, readonly) UIView* engineWebView;
31 |
32 | - (id)loadRequest:(NSURLRequest*)request;
33 | - (id)loadHTMLString:(NSString*)string baseURL:(NSURL*)baseURL;
34 | - (void)evaluateJavaScript:(NSString*)javaScriptString completionHandler:(void (^)(id, NSError*))completionHandler;
35 |
36 | - (NSURL*)URL;
37 | - (BOOL)canLoadRequest:(NSURLRequest*)request;
38 |
39 | - (instancetype)initWithFrame:(CGRect)frame;
40 | - (void)updateWithInfo:(NSDictionary*)info;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/CDVWhitelist.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | extern NSString* const kCDVDefaultWhitelistRejectionString;
23 |
24 | @interface CDVWhitelist : NSObject
25 |
26 | @property (nonatomic, copy) NSString* whitelistRejectionFormatString;
27 |
28 | - (id)initWithArray:(NSArray*)array;
29 | - (BOOL)schemeIsAllowed:(NSString*)scheme;
30 | - (BOOL)URLIsAllowed:(NSURL*)url;
31 | - (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure;
32 | - (NSString*)errorStringForURL:(NSURL*)url;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/NSDictionary+CordovaPreferences.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import
22 |
23 | @interface NSDictionary (CordovaPreferences)
24 |
25 | - (id)cordovaSettingForKey:(NSString*)key;
26 | - (BOOL)cordovaBoolSettingForKey:(NSString*)key defaultValue:(BOOL)defaultValue;
27 | - (CGFloat)cordovaFloatSettingForKey:(NSString*)key defaultValue:(CGFloat)defaultValue;
28 |
29 | @end
30 |
31 | @interface NSMutableDictionary (CordovaPreferences)
32 |
33 | - (void)setCordovaSetting:(id)value forKey:(NSString*)key;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/NSDictionary+CordovaPreferences.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "NSDictionary+CordovaPreferences.h"
21 | #import
22 |
23 | @implementation NSDictionary (CordovaPreferences)
24 |
25 | - (id)cordovaSettingForKey:(NSString*)key
26 | {
27 | return [self objectForKey:[key lowercaseString]];
28 | }
29 |
30 | - (BOOL)cordovaBoolSettingForKey:(NSString*)key defaultValue:(BOOL)defaultValue
31 | {
32 | BOOL value = defaultValue;
33 | id prefObj = [self cordovaSettingForKey:key];
34 |
35 | if (prefObj != nil) {
36 | value = [(NSNumber*)prefObj boolValue];
37 | }
38 |
39 | return value;
40 | }
41 |
42 | - (CGFloat)cordovaFloatSettingForKey:(NSString*)key defaultValue:(CGFloat)defaultValue
43 | {
44 | CGFloat value = defaultValue;
45 | id prefObj = [self cordovaSettingForKey:key];
46 |
47 | if (prefObj != nil) {
48 | value = [prefObj floatValue];
49 | }
50 |
51 | return value;
52 | }
53 |
54 | @end
55 |
56 | @implementation NSMutableDictionary (CordovaPreferences)
57 |
58 | - (void)setCordovaSetting:(id)value forKey:(NSString*)key
59 | {
60 | [self setObject:value forKey:[key lowercaseString]];
61 | }
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/NSMutableArray+QueueAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 |
22 | @interface NSMutableArray (QueueAdditions)
23 |
24 | - (id)cdv_pop;
25 | - (id)cdv_queueHead;
26 | - (id)cdv_dequeue;
27 | - (void)cdv_enqueue:(id)obj;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/Public/NSMutableArray+QueueAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import "NSMutableArray+QueueAdditions.h"
21 |
22 | @implementation NSMutableArray (QueueAdditions)
23 |
24 | - (id)cdv_queueHead
25 | {
26 | if ([self count] == 0) {
27 | return nil;
28 | }
29 |
30 | return [self objectAtIndex:0];
31 | }
32 |
33 | - (__autoreleasing id)cdv_dequeue
34 | {
35 | if ([self count] == 0) {
36 | return nil;
37 | }
38 |
39 | id head = [self objectAtIndex:0];
40 | if (head != nil) {
41 | // [[head retain] autorelease]; ARC - the __autoreleasing on the return value should so the same thing
42 | [self removeObjectAtIndex:0];
43 | }
44 |
45 | return head;
46 | }
47 |
48 | - (id)cdv_pop
49 | {
50 | return [self cdv_dequeue];
51 | }
52 |
53 | - (void)cdv_enqueue:(id)object
54 | {
55 | [self addObject:object];
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/CordovaLib/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | HelloCordova
22 |
23 | A sample Apache Cordova application that responds to the deviceready event.
24 |
25 |
26 | Apache Cordova Team
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/HLAudioPlayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // HLAudioPlayer.h
3 | // 音效播放器
4 | //
5 | // Created by Harvey on 14/6/2.
6 | // Copyright © 2014年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface HLAudioPlayer : NSObject
13 |
14 | + (AVAudioPlayer *)playMusic:(NSString *)fileName;
15 |
16 | + (void)pauseMusic:(NSString *)fileName;
17 |
18 | + (void)stopMusic:(NSString *)fileName;
19 |
20 |
21 | + (void)playSound:(NSString *)soundName;
22 |
23 | + (void)disposeSound:(NSString *)soundName;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/HLAudioPlayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // HLAudioPlayer.m
3 | // 音效播放器
4 | //
5 | // Created by Harvey on 14/6/2.
6 | // Copyright © 2014年 Haley. All rights reserved.
7 | //
8 |
9 | #import "HLAudioPlayer.h"
10 |
11 | @implementation HLAudioPlayer
12 |
13 | + (void)initialize
14 | {
15 | // 音频会话
16 | AVAudioSession *session = [AVAudioSession sharedInstance];
17 | // 设置会话类型
18 | [session setCategory:AVAudioSessionCategoryPlayback error:nil];
19 | // 激活会话
20 | [session setActive:YES error:nil];
21 | }
22 |
23 | // 音效Id
24 | static NSMutableDictionary *_soundIDs;
25 |
26 | + (NSMutableDictionary *)soundIDs
27 | {
28 | if (!_soundIDs) {
29 | _soundIDs = [NSMutableDictionary dictionary];
30 | }
31 | return _soundIDs;
32 | }
33 |
34 |
35 | // 所有的播放器
36 | static NSMutableDictionary *_musicPlayers;
37 | + (NSMutableDictionary *)musicPlayers
38 | {
39 | if (!_musicPlayers) {
40 | _musicPlayers = [NSMutableDictionary dictionary];
41 | }
42 | return _musicPlayers;
43 | }
44 |
45 | + (AVAudioPlayer *)playMusic:(NSString *)fileName
46 | {
47 | if (!fileName) {
48 | return nil;
49 | }
50 |
51 | AVAudioPlayer *player = [self musicPlayers][fileName];
52 | if (!player) {
53 | NSURL *URL = [[NSBundle mainBundle] URLForResource:fileName withExtension:nil];
54 | if (!URL) {
55 | return nil;
56 | }
57 | player = [[AVAudioPlayer alloc] initWithContentsOfURL:URL error:nil];
58 |
59 | if (![player prepareToPlay]) {
60 | return nil;
61 | }
62 |
63 | [self musicPlayers][fileName] = player;
64 | }
65 |
66 | if (!player.isPlaying) {
67 | [player play];
68 | }
69 |
70 | return player;
71 | }
72 |
73 | + (void)pauseMusic:(NSString *)fileName
74 | {
75 | if (!fileName) {
76 | return;
77 | }
78 |
79 | AVAudioPlayer *player = [self musicPlayers][fileName];
80 |
81 | [player pause];
82 | }
83 |
84 | + (void)stopMusic:(NSString *)fileName
85 | {
86 | if (!fileName) {
87 | return;
88 | }
89 |
90 | AVAudioPlayer *player = [self musicPlayers][fileName];
91 |
92 | [player stop];
93 |
94 | [[self musicPlayers] removeObjectForKey:fileName];
95 | }
96 |
97 | + (void)playSound:(NSString *)soundName
98 | {
99 | if (!soundName) {
100 | return;
101 | }
102 |
103 | SystemSoundID soundID = [[self soundIDs][soundName] unsignedIntValue];
104 |
105 | if (!soundID) {
106 | NSURL *URL = [[NSBundle mainBundle] URLForResource:soundName withExtension:nil];
107 | if (!URL) {
108 | return;
109 | }
110 |
111 | AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(URL), &soundID);
112 |
113 | [self soundIDs][soundName] = @(soundID);
114 | }
115 |
116 | AudioServicesPlaySystemSound(soundID);
117 | }
118 |
119 | + (void)disposeSound:(NSString *)soundName
120 | {
121 | if (!soundName) {
122 | return;
123 | }
124 |
125 | SystemSoundID soundID = [[self soundIDs][soundName] unsignedIntValue];
126 |
127 | if (soundID) {
128 | AudioServicesDisposeSystemSoundID(soundID);
129 |
130 | [[self soundIDs] removeObjectForKey:soundName];
131 | }
132 | }
133 |
134 | @end
135 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 |
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/Plugins/HaleyPlugin.h:
--------------------------------------------------------------------------------
1 | //
2 | // HaleyPlugin.h
3 | // HelloCordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | //
7 | //
8 |
9 | #import "CDV.h"
10 |
11 | @interface HaleyPlugin : CDVPlugin
12 |
13 | - (void)scan:(CDVInvokedUrlCommand *)command;
14 |
15 | - (void)location:(CDVInvokedUrlCommand *)command;
16 |
17 | - (void)pay:(CDVInvokedUrlCommand *)command;
18 |
19 | - (void)share:(CDVInvokedUrlCommand *)command;
20 |
21 | - (void)changeColor:(CDVInvokedUrlCommand *)command;
22 |
23 | - (void)shake:(CDVInvokedUrlCommand *)command;
24 |
25 | - (void)playSound:(CDVInvokedUrlCommand *)command;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/Plugins/HaleyPlugin.m:
--------------------------------------------------------------------------------
1 | //
2 | // HaleyPlugin.m
3 | // HelloCordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | //
7 | //
8 |
9 | #import
10 |
11 | #import "HaleyPlugin.h"
12 | #import "HLAudioPlayer.h"
13 |
14 | @implementation HaleyPlugin
15 |
16 | - (void)scan:(CDVInvokedUrlCommand *)command
17 | {
18 | [self.commandDelegate runInBackground:^{
19 | dispatch_async(dispatch_get_main_queue(), ^{
20 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"原生弹窗" message:nil delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];
21 | [alertView show];
22 | });
23 | }];
24 | }
25 |
26 | - (void)location:(CDVInvokedUrlCommand *)command
27 | {
28 | // 获取定位信息......
29 |
30 | // 下一行代码以后可以删除
31 | // NSString *locationStr = @"广东省深圳市南山区学府路XXXX号";
32 | NSString *locationStr = @"错误信息";
33 |
34 | // NSString *jsStr = [NSString stringWithFormat:@"setLocation('%@')",locationStr];
35 | // [self.commandDelegate evalJs:jsStr];
36 |
37 | [self.commandDelegate runInBackground:^{
38 | CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:locationStr];
39 | [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
40 | }];
41 | }
42 |
43 | - (void)pay:(CDVInvokedUrlCommand *)command
44 | {
45 | // 这里是支付的相关代码......
46 |
47 | // 以下代码以后可以删除
48 | NSUInteger code = 1;
49 | NSString *tip = @"支付成功";
50 | NSArray *arguments = command.arguments;
51 | if (arguments.count < 4) {;
52 | code = 2;
53 | tip = @"参数错误";
54 | } else {
55 | NSLog(@"从H5获取的支付参数:%@",arguments);
56 | }
57 |
58 | NSString *jsStr = [NSString stringWithFormat:@"payResult('%@',%lu)",tip,(unsigned long)code];
59 | [self.commandDelegate evalJs:jsStr];
60 | }
61 |
62 | - (void)share:(CDVInvokedUrlCommand *)command
63 | {
64 | NSUInteger code = 1;
65 | NSString *tip = @"分享成功";
66 | NSArray *arguments = command.arguments;
67 | if (arguments.count < 3) {;
68 | code = 2;
69 | tip = @"参数错误";
70 | NSString *jsStr = [NSString stringWithFormat:@"shareResult('%@')",tip];
71 | [self.commandDelegate evalJs:jsStr];
72 | return;
73 | }
74 |
75 | NSLog(@"从H5获取的分享参数:%@",arguments);
76 | NSString *title = arguments[0];
77 | NSString *content = arguments[1];
78 | NSString *url = arguments[2];
79 |
80 | // 这里是分享的相关代码......
81 |
82 | // 将分享结果返回给js
83 | NSString *jsStr = [NSString stringWithFormat:@"shareResult('%@','%@','%@')",title,content,url];
84 | [self.commandDelegate evalJs:jsStr];
85 | }
86 |
87 | - (void)changeColor:(CDVInvokedUrlCommand *)command
88 | {
89 | NSArray *arguments = command.arguments;
90 | if (arguments.count < 4) {
91 | return;
92 | }
93 |
94 | CGFloat r = [arguments[0] floatValue];
95 | CGFloat g = [arguments[1] floatValue];
96 | CGFloat b = [arguments[2] floatValue];
97 | CGFloat a = [arguments[3] floatValue];
98 |
99 | self.viewController.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
100 | }
101 |
102 | - (void)shake:(CDVInvokedUrlCommand *)command
103 | {
104 | [self.commandDelegate runInBackground:^{
105 | AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
106 | [HLAudioPlayer playMusic:@"shake_sound_male.wav"];
107 | }];
108 | }
109 |
110 | - (void)playSound:(CDVInvokedUrlCommand *)command
111 | {
112 | NSArray *arguments = command.arguments;
113 | if (arguments.count < 1) {
114 | return;
115 | }
116 |
117 | [self.commandDelegate runInBackground:^{
118 | NSString *fileName = arguments[0];
119 | [HLAudioPlayer playMusic:fileName];
120 | }];
121 | }
122 |
123 | @end
124 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/PrefixHeader.pch:
--------------------------------------------------------------------------------
1 | //
2 | // PrefixHeader.pch
3 | // JS_OC_Cordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #ifndef PrefixHeader_pch
10 | #define PrefixHeader_pch
11 |
12 | // Include any system framework and library headers here that should be included in all compilation units.
13 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
14 |
15 | #ifdef __OBJC__
16 | #import
17 |
18 | #endif
19 |
20 | #endif /* PrefixHeader_pch */
21 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // JS_OC_Cordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CDVViewController.h"
11 |
12 | @interface ViewController : CDVViewController
13 |
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // JS_OC_Cordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 |
19 | // self.startPage = @"http://www.baidu.com";
20 |
21 | [super viewDidLoad];
22 | // Do any additional setup after loading the view, typically from a nib.
23 |
24 | // 这里空出的20,是为了不显示使用导航控制器时,控制背景色来改变状态栏背景色
25 | self.webView.frame = CGRectMake(0, 20, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) - 20);
26 |
27 | UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"测试" style:UIBarButtonItemStylePlain target:self action:@selector(testClick)];
28 | self.navigationItem.rightBarButtonItem = rightItem;
29 | }
30 |
31 | - (void)viewWillAppear:(BOOL)animated
32 | {
33 | [super viewWillAppear:animated];
34 |
35 | [self.navigationController setNavigationBarHidden:YES];
36 |
37 | }
38 |
39 | - (void)testClick
40 | {
41 | NSString *jsStr = @"asyncAlert('哈哈啊哈')";
42 | [self.commandDelegate evalJs:jsStr];
43 | }
44 |
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JS_OC_Cordova
4 | //
5 | // Created by Harvey on 16/9/28.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JS_OC_Cordova/JS_OC_Cordova/shake_sound_male.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_Cordova/JS_OC_Cordova/shake_sound_male.wav
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/xcuserdata/haley.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/xcuserdata/haley.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_JavaScriptCore.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/xcuserdata/harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/JS_OC_JavaScriptCore.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_JavaScriptCore.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B9BCE63F1D6BEB49002CCCFB
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JS_OC_JavaScriptCore
4 | //
5 | // Created by Harvey on 16/8/23.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JS_OC_JavaScriptCore
4 | //
5 | // Created by Harvey on 16/8/23.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "MainViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
22 | self.window.backgroundColor = [UIColor whiteColor];
23 |
24 | MainViewController *mainVC = [[MainViewController alloc] init];
25 | UINavigationController *NAV = [[UINavigationController alloc] initWithRootViewController:mainVC];
26 | self.window.rootViewController = NAV;
27 |
28 | [self.window makeKeyAndVisible];
29 | return YES;
30 | }
31 |
32 | - (void)applicationWillResignActive:(UIApplication *)application {
33 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
34 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
35 | }
36 |
37 | - (void)applicationDidEnterBackground:(UIApplication *)application {
38 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
40 | }
41 |
42 | - (void)applicationWillEnterForeground:(UIApplication *)application {
43 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
44 | }
45 |
46 | - (void)applicationDidBecomeActive:(UIApplication *)application {
47 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
48 | }
49 |
50 | - (void)applicationWillTerminate:(UIApplication *)application {
51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // JS_OC_JavaScriptCore
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // JS_OC_JavaScriptCore
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 | #import "WebViewController.h"
11 |
12 | @interface MainViewController ()
13 |
14 | @end
15 |
16 | @implementation MainViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view from its nib.
21 | self.title = @"主页";
22 | }
23 |
24 | - (IBAction)btnClick1:(id)sender {
25 | WebViewController *webVC = [[WebViewController alloc] init];
26 | [self.navigationController pushViewController:webVC animated:YES];
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/MainViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/WebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewController.h
3 | // JS_OC_JavaScriptCore
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WebViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
67 |
68 |
69 |
70 | 这是按钮调用
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | 这是文件上传
81 |
82 |
83 |
84 | 这是回调结果展示区
85 |
88 |
89 | 竖直方向的表头:
90 |
91 |
92 | 姓名 |
93 | Bill Gates |
94 |
95 |
96 | 电话 |
97 | 555 77 854 |
98 |
99 |
100 | 传真 |
101 | 555 77 855 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JS_OC_JavaScriptCore
4 | //
5 | // Created by Harvey on 16/8/23.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/xcuserdata/haley.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_MessageHandler.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/xcuserdata/harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/JS_OC_MessageHandler.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_MessageHandler.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B962329F1D5494C100B2B7BB
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JS_OC_MessageHandler
4 | //
5 | // Created by Harvey on 16/8/5.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JS_OC_MessageHandler
4 | //
5 | // Created by Harvey on 16/8/5.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "MainViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 |
22 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
23 | self.window.backgroundColor = [UIColor whiteColor];
24 |
25 | MainViewController *mainVC = [[MainViewController alloc] init];
26 | UINavigationController *NAV = [[UINavigationController alloc] initWithRootViewController:mainVC];
27 | self.window.rootViewController = NAV;
28 |
29 | [self.window makeKeyAndVisible];
30 |
31 | return YES;
32 | }
33 |
34 | - (void)applicationWillResignActive:(UIApplication *)application {
35 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
36 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
37 | }
38 |
39 | - (void)applicationDidEnterBackground:(UIApplication *)application {
40 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
41 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
42 | }
43 |
44 | - (void)applicationWillEnterForeground:(UIApplication *)application {
45 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
46 | }
47 |
48 | - (void)applicationDidBecomeActive:(UIApplication *)application {
49 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
50 | }
51 |
52 | - (void)applicationWillTerminate:(UIApplication *)application {
53 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/HLAudioPlayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // HLAudioPlayer.h
3 | // 音效播放器
4 | //
5 | // Created by Harvey on 14/6/2.
6 | // Copyright © 2014年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface HLAudioPlayer : NSObject
13 |
14 | + (AVAudioPlayer *)playMusic:(NSString *)fileName;
15 |
16 | + (void)pauseMusic:(NSString *)fileName;
17 |
18 | + (void)stopMusic:(NSString *)fileName;
19 |
20 |
21 | + (void)playSound:(NSString *)soundName;
22 |
23 | + (void)disposeSound:(NSString *)soundName;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/HLAudioPlayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // HLAudioPlayer.m
3 | // 音效播放器
4 | //
5 | // Created by Harvey on 14/6/2.
6 | // Copyright © 2014年 Haley. All rights reserved.
7 | //
8 |
9 | #import "HLAudioPlayer.h"
10 |
11 | @implementation HLAudioPlayer
12 |
13 | + (void)initialize
14 | {
15 | // 音频会话
16 | AVAudioSession *session = [AVAudioSession sharedInstance];
17 | // 设置会话类型
18 | [session setCategory:AVAudioSessionCategoryPlayback error:nil];
19 | // 激活会话
20 | [session setActive:YES error:nil];
21 | }
22 |
23 | // 音效Id
24 | static NSMutableDictionary *_soundIDs;
25 |
26 | + (NSMutableDictionary *)soundIDs
27 | {
28 | if (!_soundIDs) {
29 | _soundIDs = [NSMutableDictionary dictionary];
30 | }
31 | return _soundIDs;
32 | }
33 |
34 |
35 | // 所有的播放器
36 | static NSMutableDictionary *_musicPlayers;
37 | + (NSMutableDictionary *)musicPlayers
38 | {
39 | if (!_musicPlayers) {
40 | _musicPlayers = [NSMutableDictionary dictionary];
41 | }
42 | return _musicPlayers;
43 | }
44 |
45 | + (AVAudioPlayer *)playMusic:(NSString *)fileName
46 | {
47 | if (!fileName) {
48 | return nil;
49 | }
50 |
51 | AVAudioPlayer *player = [self musicPlayers][fileName];
52 | if (!player) {
53 | NSURL *URL = [[NSBundle mainBundle] URLForResource:fileName withExtension:nil];
54 | if (!URL) {
55 | return nil;
56 | }
57 | player = [[AVAudioPlayer alloc] initWithContentsOfURL:URL error:nil];
58 |
59 | if (![player prepareToPlay]) {
60 | return nil;
61 | }
62 |
63 | [self musicPlayers][fileName] = player;
64 | }
65 |
66 | if (!player.isPlaying) {
67 | [player play];
68 | }
69 |
70 | return player;
71 | }
72 |
73 | + (void)pauseMusic:(NSString *)fileName
74 | {
75 | if (!fileName) {
76 | return;
77 | }
78 |
79 | AVAudioPlayer *player = [self musicPlayers][fileName];
80 |
81 | [player pause];
82 | }
83 |
84 | + (void)stopMusic:(NSString *)fileName
85 | {
86 | if (!fileName) {
87 | return;
88 | }
89 |
90 | AVAudioPlayer *player = [self musicPlayers][fileName];
91 |
92 | [player stop];
93 |
94 | [[self musicPlayers] removeObjectForKey:fileName];
95 | }
96 |
97 | + (void)playSound:(NSString *)soundName
98 | {
99 | if (!soundName) {
100 | return;
101 | }
102 |
103 | SystemSoundID soundID = [[self soundIDs][soundName] unsignedIntValue];
104 |
105 | if (!soundID) {
106 | NSURL *URL = [[NSBundle mainBundle] URLForResource:soundName withExtension:nil];
107 | if (!URL) {
108 | return;
109 | }
110 |
111 | AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(URL), &soundID);
112 |
113 | [self soundIDs][soundName] = @(soundID);
114 | }
115 |
116 | AudioServicesPlaySystemSound(soundID);
117 | }
118 |
119 | + (void)disposeSound:(NSString *)soundName
120 | {
121 | if (!soundName) {
122 | return;
123 | }
124 |
125 | SystemSoundID soundID = [[self soundIDs][soundName] unsignedIntValue];
126 |
127 | if (soundID) {
128 | AudioServicesDisposeSystemSoundID(soundID);
129 |
130 | [[self soundIDs] removeObjectForKey:soundName];
131 | }
132 | }
133 |
134 | @end
135 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 |
11 | #import "WKWebViewController.h"
12 |
13 | @interface MainViewController ()
14 |
15 | @end
16 |
17 | @implementation MainViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view from its nib.
22 | self.title = @"主页";
23 | }
24 |
25 | - (IBAction)btnClick2:(id)sender {
26 | WKWebViewController *wkWebVC = [[WKWebViewController alloc] init];
27 | [self.navigationController pushViewController:wkWebVC animated:YES];
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/MainViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/WKWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewController.h
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JS_OC_MessageHandler
4 | //
5 | // Created by Harvey on 16/8/5.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JS_OC_MessageHandler/JS_OC_MessageHandler/shake_sound_male.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_MessageHandler/JS_OC_MessageHandler/shake_sound_male.wav
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_URL/JS_OC_URL.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_URL/JS_OC_URL.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/xcuserdata/haley.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_URL.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/xcuserdata/harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/JS_OC_URL.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_URL.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B993203B1D52E9EE00316A6E
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "MainViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
22 | self.window.backgroundColor = [UIColor whiteColor];
23 |
24 | MainViewController *mainVC = [[MainViewController alloc] init];
25 | UINavigationController *NAV = [[UINavigationController alloc] initWithRootViewController:mainVC];
26 | self.window.rootViewController = NAV;
27 |
28 | [self.window makeKeyAndVisible];
29 |
30 | return YES;
31 | }
32 |
33 | - (void)applicationWillResignActive:(UIApplication *)application {
34 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
35 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
36 | }
37 |
38 | - (void)applicationDidEnterBackground:(UIApplication *)application {
39 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
41 | }
42 |
43 | - (void)applicationWillEnterForeground:(UIApplication *)application {
44 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
45 | }
46 |
47 | - (void)applicationDidBecomeActive:(UIApplication *)application {
48 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
49 | }
50 |
51 | - (void)applicationWillTerminate:(UIApplication *)application {
52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 |
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 | #import "WebViewController.h"
11 | #import "WKWebViewController.h"
12 |
13 | @interface MainViewController ()
14 |
15 | @end
16 |
17 | @implementation MainViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view from its nib.
22 | self.title = @"主页";
23 | }
24 |
25 | - (IBAction)btnClick1:(id)sender {
26 | WebViewController *webVC = [[WebViewController alloc] init];
27 | [self.navigationController pushViewController:webVC animated:YES];
28 | }
29 |
30 |
31 | - (IBAction)btnClick2:(id)sender {
32 | WKWebViewController *wkWebVC = [[WKWebViewController alloc] init];
33 | [self.navigationController pushViewController:wkWebVC animated:YES];
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/MainViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
29 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/WKWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewController.h
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/WebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewController.h
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WebViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_URL/JS_OC_URL/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JS_OC_URL
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge.xcodeproj/xcuserdata/harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/JS_OC_WebViewJavascriptBridge.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC_WebViewJavascriptBridge.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B95B2BBC1D6EC32E0075119B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/25.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/25.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "MainViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
22 | self.window.backgroundColor = [UIColor whiteColor];
23 |
24 | MainViewController *mainVC = [[MainViewController alloc] init];
25 | UINavigationController *NAV = [[UINavigationController alloc] initWithRootViewController:mainVC];
26 | self.window.rootViewController = NAV;
27 |
28 | [self.window makeKeyAndVisible];
29 |
30 | return YES;
31 | }
32 |
33 | - (void)applicationWillResignActive:(UIApplication *)application {
34 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
35 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
36 | }
37 |
38 | - (void)applicationDidEnterBackground:(UIApplication *)application {
39 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
41 | }
42 |
43 | - (void)applicationWillEnterForeground:(UIApplication *)application {
44 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
45 | }
46 |
47 | - (void)applicationDidBecomeActive:(UIApplication *)application {
48 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
49 | }
50 |
51 | - (void)applicationWillTerminate:(UIApplication *)application {
52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 | #import "WebViewController.h"
11 | #import "WKWebViewController.h"
12 |
13 | @interface MainViewController ()
14 |
15 | @end
16 |
17 | @implementation MainViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view from its nib.
22 | self.title = @"主页";
23 | }
24 |
25 | - (IBAction)btnClick1:(id)sender {
26 | WebViewController *webVC = [[WebViewController alloc] init];
27 | [self.navigationController pushViewController:webVC animated:YES];
28 | }
29 |
30 |
31 | - (IBAction)btnClick2:(id)sender {
32 | WKWebViewController *wkWebVC = [[WKWebViewController alloc] init];
33 | [self.navigationController pushViewController:wkWebVC animated:YES];
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/MainViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
25 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/WKWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewController.h
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WKWebViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/WebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewController.h
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/4.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WebViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewJavascriptBridge.h
3 | //
4 | // Created by @LokiMeyburg on 10/15/14.
5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved.
6 | //
7 |
8 | #if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_1)
9 | #define supportsWKWebKit
10 | #endif
11 |
12 | #if defined(supportsWKWebKit )
13 |
14 | #import
15 | #import "WebViewJavascriptBridgeBase.h"
16 | #import
17 |
18 | @interface WKWebViewJavascriptBridge : NSObject
19 |
20 | + (instancetype)bridgeForWebView:(WKWebView*)webView;
21 | + (void)enableLogging;
22 |
23 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
24 | - (void)callHandler:(NSString*)handlerName;
25 | - (void)callHandler:(NSString*)handlerName data:(id)data;
26 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
27 | - (void)reset;
28 | - (void)setWebViewDelegate:(id)webViewDelegate;
29 | - (void)disableJavscriptAlertBoxSafetyTimeout;
30 |
31 | @end
32 |
33 | #endif
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewJavascriptBridge.h
3 | // ExampleApp-iOS
4 | //
5 | // Created by Marcus Westin on 6/14/13.
6 | // Copyright (c) 2013 Marcus Westin. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WebViewJavascriptBridgeBase.h"
11 |
12 | #if defined __MAC_OS_X_VERSION_MAX_ALLOWED
13 | #import
14 | #define WVJB_PLATFORM_OSX
15 | #define WVJB_WEBVIEW_TYPE WebView
16 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
17 | #define WVJB_WEBVIEW_DELEGATE_INTERFACE NSObject
18 | #elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
19 | #import
20 | #define WVJB_PLATFORM_IOS
21 | #define WVJB_WEBVIEW_TYPE UIWebView
22 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
23 | #define WVJB_WEBVIEW_DELEGATE_INTERFACE NSObject
24 | #endif
25 |
26 | @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE
27 |
28 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView;
29 | + (void)enableLogging;
30 | + (void)setLogMaxLength:(int)length;
31 |
32 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
33 | - (void)callHandler:(NSString*)handlerName;
34 | - (void)callHandler:(NSString*)handlerName data:(id)data;
35 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
36 | - (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate;
37 | - (void)disableJavscriptAlertBoxSafetyTimeout;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewJavascriptBridgeBase.h
3 | //
4 | // Created by @LokiMeyburg on 10/15/14.
5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | #define kCustomProtocolScheme @"wvjbscheme"
11 | #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__"
12 | #define kBridgeLoaded @"__BRIDGE_LOADED__"
13 |
14 | typedef void (^WVJBResponseCallback)(id responseData);
15 | typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
16 | typedef NSDictionary WVJBMessage;
17 |
18 | @protocol WebViewJavascriptBridgeBaseDelegate
19 | - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand;
20 | @end
21 |
22 | @interface WebViewJavascriptBridgeBase : NSObject
23 |
24 |
25 | @property (weak, nonatomic) id delegate;
26 | @property (strong, nonatomic) NSMutableArray* startupMessageQueue;
27 | @property (strong, nonatomic) NSMutableDictionary* responseCallbacks;
28 | @property (strong, nonatomic) NSMutableDictionary* messageHandlers;
29 | @property (strong, nonatomic) WVJBHandler messageHandler;
30 |
31 | + (void)enableLogging;
32 | + (void)setLogMaxLength:(int)length;
33 | - (void)reset;
34 | - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName;
35 | - (void)flushMessageQueue:(NSString *)messageQueueString;
36 | - (void)injectJavascriptFile;
37 | - (BOOL)isCorrectProcotocolScheme:(NSURL*)url;
38 | - (BOOL)isQueueMessageURL:(NSURL*)urll;
39 | - (BOOL)isBridgeLoadedURL:(NSURL*)urll;
40 | - (void)logUnkownMessage:(NSURL*)url;
41 | - (NSString *)webViewJavascriptCheckCommand;
42 | - (NSString *)webViewJavascriptFetchQueyCommand;
43 | - (void)disableJavscriptAlertBoxSafetyTimeout;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | NSString * WebViewJavascriptBridge_js();
--------------------------------------------------------------------------------
/JS_OC_WebViewJavascriptBridge/JS_OC_WebViewJavascriptBridge/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JS_OC_WebViewJavascriptBridge
4 | //
5 | // Created by Harvey on 16/8/25.
6 | // Copyright © 2016年 Haley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/project.xcworkspace/xcuserdata/Harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_summary/JS_OC.xcodeproj/project.xcworkspace/xcuserdata/Harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_summary/JS_OC.xcodeproj/project.xcworkspace/xcuserdata/haley.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/xcuserdata/Harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/xcuserdata/Harvey.xcuserdatad/xcschemes/JS_OC.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/xcuserdata/Harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B93B1C881BEDC7D7009C86FA
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/xcuserdata/haley.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC.xcodeproj/xcuserdata/haley.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | JS_OC.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/First.html:
--------------------------------------------------------------------------------
1 |
2 |
28 |
29 |
30 | 这里是第一种方式
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/FirstViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // FirstViewController.h
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface FirstViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/FirstViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // FirstViewController.m
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import "FirstViewController.h"
10 |
11 | @interface FirstViewController ()
12 |
13 | @property (weak, nonatomic) IBOutlet UIWebView *webView;
14 |
15 | @end
16 |
17 | @implementation FirstViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view.
22 |
23 | _webView.backgroundColor = [UIColor redColor];
24 | _webView.delegate = self;
25 | NSString *path = [[NSBundle mainBundle] pathForResource:@"First" ofType:@"html"];
26 | NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:path]];
27 | [_webView loadRequest:request];
28 |
29 | UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"调JS" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction)];
30 | self.navigationItem.rightBarButtonItem = rightItem;
31 |
32 | }
33 |
34 | - (void)rightAction
35 | {
36 | NSString *jsStr = [NSString stringWithFormat:@"showAlert('%@')",@"这里是JS中alert弹出的message"];
37 | [_webView stringByEvaluatingJavaScriptFromString:jsStr];
38 | }
39 |
40 | #pragma mark - UIWebViewDelegate
41 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
42 | {
43 | NSURL * url = [request URL];
44 | if ([[url scheme] isEqualToString:@"firstclick"]) {
45 | NSArray *params =[url.query componentsSeparatedByString:@"&"];
46 |
47 | NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
48 | for (NSString *paramStr in params) {
49 | NSArray *dicArray = [paramStr componentsSeparatedByString:@"="];
50 | if (dicArray.count > 1) {
51 | NSString *decodeValue = [dicArray[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
52 | [tempDic setObject:decodeValue forKey:dicArray[0]];
53 | }
54 | }
55 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"方式一" message:@"这是OC原生的弹出窗" delegate:self cancelButtonTitle:@"收到" otherButtonTitles:nil];
56 | [alertView show];
57 | NSLog(@"tempDic:%@",tempDic);
58 | return NO;
59 | }
60 |
61 | return YES;
62 | }
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/Second.html:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | 这里是第二种方式
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/SeondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SeondViewController.h
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SeondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/SeondViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SeondViewController.m
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "SeondViewController.h"
12 |
13 | @interface SeondViewController ()
14 |
15 | @property (weak, nonatomic) IBOutlet UIWebView *webView;
16 | @end
17 |
18 | @implementation SeondViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | // Do any additional setup after loading the view.
23 |
24 | UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"调JS" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction)];
25 | self.navigationItem.rightBarButtonItem = rightItem;
26 |
27 | NSString *path = [[NSBundle mainBundle] pathForResource:@"Second" ofType:@"html"];
28 | NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:path]];
29 | [_webView loadRequest:request];
30 |
31 | JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
32 | //定义好JS要调用的方法, share就是调用的share方法名
33 | context[@"share"] = ^() {
34 | NSLog(@"+++++++Begin Log+++++++");
35 | NSArray *args = [JSContext currentArguments];
36 |
37 | dispatch_async(dispatch_get_main_queue(), ^{
38 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"方式二" message:@"这是OC原生的弹出窗" delegate:self cancelButtonTitle:@"收到" otherButtonTitles:nil];
39 | [alertView show];
40 | });
41 |
42 | for (JSValue *jsVal in args) {
43 | NSLog(@"%@", jsVal.toString);
44 | }
45 |
46 | NSLog(@"-------End Log-------");
47 | };
48 | }
49 |
50 | - (void)rightAction
51 | {
52 | JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
53 | NSString *textJS = @"showAlert('这里是JS中alert弹出的message')";
54 | [context evaluateScript:textJS];
55 | }
56 |
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/JS_OC_summary/JS_OC/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JS_OC
4 | //
5 | // Created by Harvey on 15/11/7.
6 | // Copyright © 2015年 Halley. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JS_OC_summary/Simulator Screen 11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_summary/Simulator Screen 11.png
--------------------------------------------------------------------------------
/JS_OC_summary/Simulator Screen 12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_summary/Simulator Screen 12.png
--------------------------------------------------------------------------------
/JS_OC_summary/Simulator Screen 21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_summary/Simulator Screen 21.png
--------------------------------------------------------------------------------
/JS_OC_summary/Simulator Screen 22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/JS_OC/bf1efa775e0bbac9e06851bc3f3a105be88af4fe/JS_OC_summary/Simulator Screen 22.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JS_OC
2 | JS与原生OC互相调用的Demo(持续更新中),如果帮助到你理解JS与iOS Native的交互,麻烦给个star ⭐️ ⭐️。
3 | 计划整理的JS与OC调用的系列包括:
4 | * 1.在JS 中做一次URL跳转,然后在OC中拦截跳转。(这里分为UIWebView 和 WKWebView两种,去年因为还要兼容iOS 6,所以没办法只能采用UIWebView来做。)
5 | * 2.利用WKWebView 的MessageHandler。
6 | * 3.利用系统库JavaScriptCore,来做相互调用。(iOS 7推出的)
7 | * 4.利用第三方库WebViewJavascriptBridge。
8 | * 5.利用第三方cordova库,以前叫PhoneGap。(这是一个库平台的库)
9 | * 6.当下盛行的React Native。
10 |
11 | ## JS_OC_summary
12 | [JS_OC_summary](https://github.com/Haley-Wong/JS_OC/tree/master/JS_OC_summary)是2015年中整理的两种调用方式,包括通过URL和JavaScriptCore来实现调用
13 | 在最新的示例中都有做更新和优化。
14 | 相关文章地址:
15 | [iOS下JS与原生OC互相调用(总结)](http://www.jianshu.com/p/d19689e0ed83)
16 |
17 | ## JS_OC_URL
18 | [JS_OC_URL](https://github.com/Haley-Wong/JS_OC/tree/master/JS_OC_URL)展示了UIWebView和WKWebView通过URL来实现JS调用原生OC的示例。
19 | 在JS_OC_summary的基础上有了点小小的优化。
20 | 相关文章地址:
21 | [iOS下JS与OC互相调用(一)--UIWebView 拦截URL](http://www.jianshu.com/p/7151987f012d)
22 | [iOS下JS与OC互相调用(二)--WKWebView 拦截URL](http://www.jianshu.com/p/99c3af6894f4)
23 |
24 | ## JS_OC_MessageHandler
25 | [JS_OC_MessageHandler](https://github.com/Haley-Wong/JS_OC/tree/master/JS_OC_MessageHandler)是利用WKWebView提供的新的API实现的JS调用原生OC,更简洁和方便。
26 | 相关文章地址:
27 | [iOS下JS与OC互相调用(三)--MessageHandler](http://www.jianshu.com/p/433e59c5a9eb)
28 |
29 | ## JS_OC_JavaScriptCore
30 | [JS_OC_JavaScriptCore](https://github.com/Haley-Wong/JS_OC/tree/master/JS_OC_JavaScriptCore)是利用JavaScriptCore框架来实现JS与OC相互调用的示例。
31 | 相关文章地址:
32 | [iOS下JS与OC互相调用(四)--JavaScriptCore](http://www.jianshu.com/p/4db513ed2c1a)
33 |
34 | ## JS_OC_WebViewJavascriptBridge
35 | [JS_OC_WebViewJavascriptBridge](https://github.com/Haley-Wong/JS_OC/tree/master/JS_OC_WebViewJavascriptBridge)是通过第三方框架[WebViewJavascriptBridge]()来实现JS与OC交互的示例。
36 | 相关文章地址:
37 | [iOS下JS与OC互相调用(五)--UIWebView + WebViewJavascriptBridge](http://www.jianshu.com/p/2be213e3f673)
38 | [iOS下JS与OC互相调用(六)--WKWebView + WebViewJavascriptBridge](http://www.jianshu.com/p/e951af9e5e74)
39 |
40 | > 目前我Demo中的WebViewJavascriptBridge库不是最新版本,在最新的iOS系统有崩溃,各位在使用该第三方库时,记得先更新到最新版本。
41 |
42 | ## JS_OC_Cordova
43 | [JS_OC_Cordova](https://github.com/Haley-Wong/JS_OC/tree/master/JS_OC_Cordova)是通过第三方框架Cordova来实现JS与OC交互的示例。
44 | 相关文章地址:
45 | [iOS下JS与OC互相调用(七)--Cordova 基础](http://www.jianshu.com/p/78e486b31953)
46 | [iOS下JS与OC互相调用(八)--Cordova详解+实战](http://www.jianshu.com/p/e74bc7abac8d)
47 |
48 | 简书和csdn 下分别有一个专题,还在持续更新中:
49 | 简书:[JS与OC交互](http://www.jianshu.com/notebooks/5513092/latest)
50 |
51 | csdn:[iOS 原生与 JS 交互](http://blog.csdn.net/column/details/12696.html)
52 |
53 |
54 | 其他几篇待续。
55 |
--------------------------------------------------------------------------------