├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── Headers │ ├── Private │ │ └── WebViewJavascriptBridge │ │ │ ├── WKWebViewJavascriptBridge.h │ │ │ ├── WebViewJavascriptBridge.h │ │ │ ├── WebViewJavascriptBridgeBase.h │ │ │ └── WebViewJavascriptBridge_JS.h │ └── Public │ │ └── WebViewJavascriptBridge │ │ ├── WKWebViewJavascriptBridge.h │ │ ├── WebViewJavascriptBridge.h │ │ └── WebViewJavascriptBridgeBase.h ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── huangyibiao.xcuserdatad │ │ └── xcschemes │ │ ├── Pods-WebViewBridgeDemo.xcscheme │ │ ├── WebViewJavascriptBridge.xcscheme │ │ └── xcschememanagement.plist ├── Target Support Files │ ├── Pods-WebViewBridgeDemo │ │ ├── Pods-WebViewBridgeDemo-acknowledgements.markdown │ │ ├── Pods-WebViewBridgeDemo-acknowledgements.plist │ │ ├── Pods-WebViewBridgeDemo-dummy.m │ │ ├── Pods-WebViewBridgeDemo-resources.sh │ │ ├── Pods-WebViewBridgeDemo.debug.xcconfig │ │ └── Pods-WebViewBridgeDemo.release.xcconfig │ └── WebViewJavascriptBridge │ │ ├── WebViewJavascriptBridge-Private.xcconfig │ │ ├── WebViewJavascriptBridge-dummy.m │ │ ├── WebViewJavascriptBridge-prefix.pch │ │ └── WebViewJavascriptBridge.xcconfig └── WebViewJavascriptBridge │ ├── LICENSE │ ├── README.md │ └── WebViewJavascriptBridge │ ├── WKWebViewJavascriptBridge.h │ ├── WKWebViewJavascriptBridge.m │ ├── WebViewJavascriptBridge.h │ ├── WebViewJavascriptBridge.m │ ├── WebViewJavascriptBridgeBase.h │ ├── WebViewJavascriptBridgeBase.m │ ├── WebViewJavascriptBridge_JS.h │ └── WebViewJavascriptBridge_JS.m ├── README.md ├── WebViewBridgeDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── huangyibiao.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── huangyibiao.xcuserdatad │ └── xcschemes │ ├── WebViewBridgeDemo.xcscheme │ └── xcschememanagement.plist ├── WebViewBridgeDemo.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── huangyibiao.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── WebViewBridgeDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── main.m └── test.html ├── WebViewBridgeDemoTests ├── Info.plist └── WebViewBridgeDemoTests.m └── WebViewBridgeDemoUITests ├── Info.plist └── WebViewBridgeDemoUITests.m /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 JackyHuang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | target 'WebViewBridgeDemo' do 2 | 3 | pod 'WebViewJavascriptBridge', '~> 5.0' 4 | 5 | end 6 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - WebViewJavascriptBridge (5.0.5) 3 | 4 | DEPENDENCIES: 5 | - WebViewJavascriptBridge (~> 5.0) 6 | 7 | SPEC CHECKSUMS: 8 | WebViewJavascriptBridge: a4d502315f1b8d9a51cd6a9174147ed567ec3bc5 9 | 10 | COCOAPODS: 0.38.2 11 | -------------------------------------------------------------------------------- /Pods/Headers/Private/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h -------------------------------------------------------------------------------- /Pods/Headers/Private/WebViewJavascriptBridge/WebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge.h -------------------------------------------------------------------------------- /Pods/Headers/Private/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h -------------------------------------------------------------------------------- /Pods/Headers/Private/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h -------------------------------------------------------------------------------- /Pods/Headers/Public/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h -------------------------------------------------------------------------------- /Pods/Headers/Public/WebViewJavascriptBridge/WebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge.h -------------------------------------------------------------------------------- /Pods/Headers/Public/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h: -------------------------------------------------------------------------------- 1 | ../../../WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - WebViewJavascriptBridge (5.0.5) 3 | 4 | DEPENDENCIES: 5 | - WebViewJavascriptBridge (~> 5.0) 6 | 7 | SPEC CHECKSUMS: 8 | WebViewJavascriptBridge: a4d502315f1b8d9a51cd6a9174147ed567ec3bc5 9 | 10 | COCOAPODS: 0.38.2 11 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0A1DF5F1BA46AFCEBE65D7FC2950A045 /* Pods-WebViewBridgeDemo-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 83C749CFAC9F7AD22AB2792D9BC9914D /* Pods-WebViewBridgeDemo-dummy.m */; }; 11 | 0EDA3651BD0EED733A054AE36AD08682 /* WebViewJavascriptBridgeBase.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8EB2D52828D794988E91A76C1F93E7 /* WebViewJavascriptBridgeBase.h */; }; 12 | 16146BB3BD291490A4389E645CD9FB38 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63003C2DBFE25A51B99BDB3658389CAD /* Foundation.framework */; }; 13 | 3459A1CF2517DEB2157C59A55994E27F /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = B22C42ABA3F28B5AFBA2FBAEE76B5A41 /* WKWebViewJavascriptBridge.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; 14 | 4A312B4C37B4359F744DA1A1EF7D268F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93C3F443CEB0DFCCF39808F75EB91FFB /* UIKit.framework */; }; 15 | 5CCB98AAA46D88991CB77EB3B104E204 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63003C2DBFE25A51B99BDB3658389CAD /* Foundation.framework */; }; 16 | 6E1E453EB87982190945964576B5649D /* WebViewJavascriptBridge-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D23FCB301D1BAB263892035E2424A7 /* WebViewJavascriptBridge-dummy.m */; }; 17 | 7C107E493659557E5F436996109F9389 /* WebViewJavascriptBridge_JS.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EFC16539B6C6A3581FC1BF6F6771180 /* WebViewJavascriptBridge_JS.h */; }; 18 | 82D9BE8B5EE0F220352A0FB010789295 /* WKWebViewJavascriptBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = F70A4C3B4377C1CA66E1B8129BD9974E /* WKWebViewJavascriptBridge.h */; }; 19 | A1384E438C20EC32E7261D2CA7F4C080 /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = C9837E70B18FE912067413C66B8E49AE /* WebViewJavascriptBridgeBase.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; 20 | C3A7F5F95B4D236F72569BC5E3113288 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 71597A8EEA251F2C72E3EE67FB2ACE4E /* WebViewJavascriptBridge_JS.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; 21 | F723BF27D2B904139DC1A218CE1D2BB4 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = E216197202521AB9CBFC1AA9DCA88BA4 /* WebViewJavascriptBridge.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; 22 | FDA26EEB03FA7B8E00EB5E5C12258F1F /* WebViewJavascriptBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = D4F5619B89C4495250240839E5C0C033 /* WebViewJavascriptBridge.h */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 5F9E10CCF540B5859DDB8FC469BD6E54 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 477CB162EF755578CADCDFAD4AA26874; 31 | remoteInfo = WebViewJavascriptBridge; 32 | }; 33 | /* End PBXContainerItemProxy section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | 0EC8AEA8E01F5E56B0A80FC6366E67BA /* Pods-WebViewBridgeDemo-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-WebViewBridgeDemo-acknowledgements.plist"; sourceTree = ""; }; 37 | 19D1EF9947F63D919F2229C2DC590C3B /* WebViewJavascriptBridge.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = WebViewJavascriptBridge.xcconfig; sourceTree = ""; }; 38 | 2B67F634AF56E551708EF9B7DCD55C3F /* WebViewJavascriptBridge-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "WebViewJavascriptBridge-Private.xcconfig"; sourceTree = ""; }; 39 | 2EFC16539B6C6A3581FC1BF6F6771180 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = WebViewJavascriptBridge_JS.h; path = WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h; sourceTree = ""; }; 40 | 39A985F2F0CA842CC568F97FAFFB7BD9 /* Pods-WebViewBridgeDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-WebViewBridgeDemo.debug.xcconfig"; sourceTree = ""; }; 41 | 45A48248024DC4650E4151EDCFF71F16 /* Pods-WebViewBridgeDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-WebViewBridgeDemo.release.xcconfig"; sourceTree = ""; }; 42 | 5F77D968426AA6150F03EE1474B71242 /* WebViewJavascriptBridge-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "WebViewJavascriptBridge-prefix.pch"; sourceTree = ""; }; 43 | 6209EE4DE3CF1803E74E05459F591740 /* Pods-WebViewBridgeDemo-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-WebViewBridgeDemo-resources.sh"; sourceTree = ""; }; 44 | 63003C2DBFE25A51B99BDB3658389CAD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 45 | 71597A8EEA251F2C72E3EE67FB2ACE4E /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = WebViewJavascriptBridge_JS.m; path = WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m; sourceTree = ""; }; 46 | 83C749CFAC9F7AD22AB2792D9BC9914D /* Pods-WebViewBridgeDemo-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-WebViewBridgeDemo-dummy.m"; sourceTree = ""; }; 47 | 93C3F443CEB0DFCCF39808F75EB91FFB /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 48 | A4E9A2D8FC2C8D0A3D5D0855EDD56E4B /* Pods-WebViewBridgeDemo-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-WebViewBridgeDemo-acknowledgements.markdown"; sourceTree = ""; }; 49 | B0D23FCB301D1BAB263892035E2424A7 /* WebViewJavascriptBridge-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "WebViewJavascriptBridge-dummy.m"; sourceTree = ""; }; 50 | B22C42ABA3F28B5AFBA2FBAEE76B5A41 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = WKWebViewJavascriptBridge.m; path = WebViewJavascriptBridge/WKWebViewJavascriptBridge.m; sourceTree = ""; }; 51 | BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 52 | C9837E70B18FE912067413C66B8E49AE /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = WebViewJavascriptBridgeBase.m; path = WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m; sourceTree = ""; }; 53 | C9C5ED3FF82FE201F5B35326D170FDE2 /* libWebViewJavascriptBridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWebViewJavascriptBridge.a; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | D4F5619B89C4495250240839E5C0C033 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = WebViewJavascriptBridge.h; path = WebViewJavascriptBridge/WebViewJavascriptBridge.h; sourceTree = ""; }; 55 | DA8EB2D52828D794988E91A76C1F93E7 /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = WebViewJavascriptBridgeBase.h; path = WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h; sourceTree = ""; }; 56 | E216197202521AB9CBFC1AA9DCA88BA4 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = WebViewJavascriptBridge.m; path = WebViewJavascriptBridge/WebViewJavascriptBridge.m; sourceTree = ""; }; 57 | EE9F9BC5F12CB89A2C8F0661A13E8867 /* libPods-WebViewBridgeDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-WebViewBridgeDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | F70A4C3B4377C1CA66E1B8129BD9974E /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = WKWebViewJavascriptBridge.h; path = WebViewJavascriptBridge/WKWebViewJavascriptBridge.h; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | B822878D16F2223AE4AF14B94B9CF808 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 5CCB98AAA46D88991CB77EB3B104E204 /* Foundation.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | D3F238754C2F8AD4A9BF514A7C925A0E /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | 16146BB3BD291490A4389E645CD9FB38 /* Foundation.framework in Frameworks */, 75 | 4A312B4C37B4359F744DA1A1EF7D268F /* UIKit.framework in Frameworks */, 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXFrameworksBuildPhase section */ 80 | 81 | /* Begin PBXGroup section */ 82 | 2CAD98808D16857DA116C594AE9B3E53 /* WebViewJavascriptBridge */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | F70A4C3B4377C1CA66E1B8129BD9974E /* WKWebViewJavascriptBridge.h */, 86 | B22C42ABA3F28B5AFBA2FBAEE76B5A41 /* WKWebViewJavascriptBridge.m */, 87 | D4F5619B89C4495250240839E5C0C033 /* WebViewJavascriptBridge.h */, 88 | E216197202521AB9CBFC1AA9DCA88BA4 /* WebViewJavascriptBridge.m */, 89 | DA8EB2D52828D794988E91A76C1F93E7 /* WebViewJavascriptBridgeBase.h */, 90 | C9837E70B18FE912067413C66B8E49AE /* WebViewJavascriptBridgeBase.m */, 91 | 2EFC16539B6C6A3581FC1BF6F6771180 /* WebViewJavascriptBridge_JS.h */, 92 | 71597A8EEA251F2C72E3EE67FB2ACE4E /* WebViewJavascriptBridge_JS.m */, 93 | F8B234176DA1E76E21DEC9804C7D9925 /* Support Files */, 94 | ); 95 | path = WebViewJavascriptBridge; 96 | sourceTree = ""; 97 | }; 98 | 433CD3331B6C3787F473C941B61FC68F /* Frameworks */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | D0FB9306D21AF23A056944AE037CBFFF /* iOS */, 102 | ); 103 | name = Frameworks; 104 | sourceTree = ""; 105 | }; 106 | 7DB346D0F39D3F0E887471402A8071AB = { 107 | isa = PBXGroup; 108 | children = ( 109 | BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */, 110 | 433CD3331B6C3787F473C941B61FC68F /* Frameworks */, 111 | C1E81C415E68AF704EDFA5CB7FF5AFD8 /* Pods */, 112 | CCA510CFBEA2D207524CDA0D73C3B561 /* Products */, 113 | E8652A42EFA23C811CCF9FC5E3933D04 /* Targets Support Files */, 114 | ); 115 | sourceTree = ""; 116 | }; 117 | C1E81C415E68AF704EDFA5CB7FF5AFD8 /* Pods */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 2CAD98808D16857DA116C594AE9B3E53 /* WebViewJavascriptBridge */, 121 | ); 122 | name = Pods; 123 | sourceTree = ""; 124 | }; 125 | CCA510CFBEA2D207524CDA0D73C3B561 /* Products */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | EE9F9BC5F12CB89A2C8F0661A13E8867 /* libPods-WebViewBridgeDemo.a */, 129 | C9C5ED3FF82FE201F5B35326D170FDE2 /* libWebViewJavascriptBridge.a */, 130 | ); 131 | name = Products; 132 | sourceTree = ""; 133 | }; 134 | D0FB9306D21AF23A056944AE037CBFFF /* iOS */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 63003C2DBFE25A51B99BDB3658389CAD /* Foundation.framework */, 138 | 93C3F443CEB0DFCCF39808F75EB91FFB /* UIKit.framework */, 139 | ); 140 | name = iOS; 141 | sourceTree = ""; 142 | }; 143 | D9C7F4D41EE417A1EE7F9169399D2B02 /* Pods-WebViewBridgeDemo */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | A4E9A2D8FC2C8D0A3D5D0855EDD56E4B /* Pods-WebViewBridgeDemo-acknowledgements.markdown */, 147 | 0EC8AEA8E01F5E56B0A80FC6366E67BA /* Pods-WebViewBridgeDemo-acknowledgements.plist */, 148 | 83C749CFAC9F7AD22AB2792D9BC9914D /* Pods-WebViewBridgeDemo-dummy.m */, 149 | 6209EE4DE3CF1803E74E05459F591740 /* Pods-WebViewBridgeDemo-resources.sh */, 150 | 39A985F2F0CA842CC568F97FAFFB7BD9 /* Pods-WebViewBridgeDemo.debug.xcconfig */, 151 | 45A48248024DC4650E4151EDCFF71F16 /* Pods-WebViewBridgeDemo.release.xcconfig */, 152 | ); 153 | name = "Pods-WebViewBridgeDemo"; 154 | path = "Target Support Files/Pods-WebViewBridgeDemo"; 155 | sourceTree = ""; 156 | }; 157 | E8652A42EFA23C811CCF9FC5E3933D04 /* Targets Support Files */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | D9C7F4D41EE417A1EE7F9169399D2B02 /* Pods-WebViewBridgeDemo */, 161 | ); 162 | name = "Targets Support Files"; 163 | sourceTree = ""; 164 | }; 165 | F8B234176DA1E76E21DEC9804C7D9925 /* Support Files */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 19D1EF9947F63D919F2229C2DC590C3B /* WebViewJavascriptBridge.xcconfig */, 169 | 2B67F634AF56E551708EF9B7DCD55C3F /* WebViewJavascriptBridge-Private.xcconfig */, 170 | B0D23FCB301D1BAB263892035E2424A7 /* WebViewJavascriptBridge-dummy.m */, 171 | 5F77D968426AA6150F03EE1474B71242 /* WebViewJavascriptBridge-prefix.pch */, 172 | ); 173 | name = "Support Files"; 174 | path = "../Target Support Files/WebViewJavascriptBridge"; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXGroup section */ 178 | 179 | /* Begin PBXHeadersBuildPhase section */ 180 | FC0EEB222BFE1E83C7A8D073E7CE4156 /* Headers */ = { 181 | isa = PBXHeadersBuildPhase; 182 | buildActionMask = 2147483647; 183 | files = ( 184 | 82D9BE8B5EE0F220352A0FB010789295 /* WKWebViewJavascriptBridge.h in Headers */, 185 | FDA26EEB03FA7B8E00EB5E5C12258F1F /* WebViewJavascriptBridge.h in Headers */, 186 | 0EDA3651BD0EED733A054AE36AD08682 /* WebViewJavascriptBridgeBase.h in Headers */, 187 | 7C107E493659557E5F436996109F9389 /* WebViewJavascriptBridge_JS.h in Headers */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXHeadersBuildPhase section */ 192 | 193 | /* Begin PBXNativeTarget section */ 194 | 477CB162EF755578CADCDFAD4AA26874 /* WebViewJavascriptBridge */ = { 195 | isa = PBXNativeTarget; 196 | buildConfigurationList = C4EFF457CC3A797CFBE7FC0FC2EC76A5 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */; 197 | buildPhases = ( 198 | B40F7D111997F7F514DA657B11A52383 /* Sources */, 199 | D3F238754C2F8AD4A9BF514A7C925A0E /* Frameworks */, 200 | FC0EEB222BFE1E83C7A8D073E7CE4156 /* Headers */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | ); 206 | name = WebViewJavascriptBridge; 207 | productName = WebViewJavascriptBridge; 208 | productReference = C9C5ED3FF82FE201F5B35326D170FDE2 /* libWebViewJavascriptBridge.a */; 209 | productType = "com.apple.product-type.library.static"; 210 | }; 211 | B5C58B7038FC798C8176028788947AB5 /* Pods-WebViewBridgeDemo */ = { 212 | isa = PBXNativeTarget; 213 | buildConfigurationList = 14CA6CBC2A07FD0E37684C2E6C15704A /* Build configuration list for PBXNativeTarget "Pods-WebViewBridgeDemo" */; 214 | buildPhases = ( 215 | ED77557322F3ACC7CA58C2ECDDD08C53 /* Sources */, 216 | B822878D16F2223AE4AF14B94B9CF808 /* Frameworks */, 217 | ); 218 | buildRules = ( 219 | ); 220 | dependencies = ( 221 | D5AC98FF928E4544D5F25CA563E17554 /* PBXTargetDependency */, 222 | ); 223 | name = "Pods-WebViewBridgeDemo"; 224 | productName = "Pods-WebViewBridgeDemo"; 225 | productReference = EE9F9BC5F12CB89A2C8F0661A13E8867 /* libPods-WebViewBridgeDemo.a */; 226 | productType = "com.apple.product-type.library.static"; 227 | }; 228 | /* End PBXNativeTarget section */ 229 | 230 | /* Begin PBXProject section */ 231 | D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { 232 | isa = PBXProject; 233 | attributes = { 234 | LastSwiftUpdateCheck = 0700; 235 | LastUpgradeCheck = 0700; 236 | }; 237 | buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; 238 | compatibilityVersion = "Xcode 3.2"; 239 | developmentRegion = English; 240 | hasScannedForEncodings = 0; 241 | knownRegions = ( 242 | en, 243 | ); 244 | mainGroup = 7DB346D0F39D3F0E887471402A8071AB; 245 | productRefGroup = CCA510CFBEA2D207524CDA0D73C3B561 /* Products */; 246 | projectDirPath = ""; 247 | projectRoot = ""; 248 | targets = ( 249 | B5C58B7038FC798C8176028788947AB5 /* Pods-WebViewBridgeDemo */, 250 | 477CB162EF755578CADCDFAD4AA26874 /* WebViewJavascriptBridge */, 251 | ); 252 | }; 253 | /* End PBXProject section */ 254 | 255 | /* Begin PBXSourcesBuildPhase section */ 256 | B40F7D111997F7F514DA657B11A52383 /* Sources */ = { 257 | isa = PBXSourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | 3459A1CF2517DEB2157C59A55994E27F /* WKWebViewJavascriptBridge.m in Sources */, 261 | 6E1E453EB87982190945964576B5649D /* WebViewJavascriptBridge-dummy.m in Sources */, 262 | F723BF27D2B904139DC1A218CE1D2BB4 /* WebViewJavascriptBridge.m in Sources */, 263 | A1384E438C20EC32E7261D2CA7F4C080 /* WebViewJavascriptBridgeBase.m in Sources */, 264 | C3A7F5F95B4D236F72569BC5E3113288 /* WebViewJavascriptBridge_JS.m in Sources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | ED77557322F3ACC7CA58C2ECDDD08C53 /* Sources */ = { 269 | isa = PBXSourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | 0A1DF5F1BA46AFCEBE65D7FC2950A045 /* Pods-WebViewBridgeDemo-dummy.m in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXSourcesBuildPhase section */ 277 | 278 | /* Begin PBXTargetDependency section */ 279 | D5AC98FF928E4544D5F25CA563E17554 /* PBXTargetDependency */ = { 280 | isa = PBXTargetDependency; 281 | name = WebViewJavascriptBridge; 282 | target = 477CB162EF755578CADCDFAD4AA26874 /* WebViewJavascriptBridge */; 283 | targetProxy = 5F9E10CCF540B5859DDB8FC469BD6E54 /* PBXContainerItemProxy */; 284 | }; 285 | /* End PBXTargetDependency section */ 286 | 287 | /* Begin XCBuildConfiguration section */ 288 | 2A879E50B313B30B09DBA82035412944 /* Release */ = { 289 | isa = XCBuildConfiguration; 290 | baseConfigurationReference = 2B67F634AF56E551708EF9B7DCD55C3F /* WebViewJavascriptBridge-Private.xcconfig */; 291 | buildSettings = { 292 | ENABLE_STRICT_OBJC_MSGSEND = YES; 293 | GCC_PREFIX_HEADER = "Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch"; 294 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 295 | MTL_ENABLE_DEBUG_INFO = NO; 296 | OTHER_LDFLAGS = ""; 297 | OTHER_LIBTOOLFLAGS = ""; 298 | PRODUCT_NAME = "$(TARGET_NAME)"; 299 | SDKROOT = iphoneos; 300 | SKIP_INSTALL = YES; 301 | }; 302 | name = Release; 303 | }; 304 | 8D1534490D941DCA47C62AC4314182AF /* Debug */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ALWAYS_SEARCH_USER_PATHS = NO; 308 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 309 | CLANG_CXX_LIBRARY = "libc++"; 310 | CLANG_ENABLE_MODULES = YES; 311 | CLANG_ENABLE_OBJC_ARC = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_CONSTANT_CONVERSION = YES; 314 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; 315 | CLANG_WARN_EMPTY_BODY = YES; 316 | CLANG_WARN_ENUM_CONVERSION = YES; 317 | CLANG_WARN_INT_CONVERSION = YES; 318 | CLANG_WARN_OBJC_ROOT_CLASS = YES; 319 | CLANG_WARN_UNREACHABLE_CODE = YES; 320 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 321 | COPY_PHASE_STRIP = NO; 322 | GCC_C_LANGUAGE_STANDARD = gnu99; 323 | GCC_DYNAMIC_NO_PIC = NO; 324 | GCC_OPTIMIZATION_LEVEL = 0; 325 | GCC_PREPROCESSOR_DEFINITIONS = ( 326 | "DEBUG=1", 327 | "$(inherited)", 328 | ); 329 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 330 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 331 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 332 | GCC_WARN_UNDECLARED_SELECTOR = YES; 333 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 334 | GCC_WARN_UNUSED_FUNCTION = YES; 335 | GCC_WARN_UNUSED_VARIABLE = YES; 336 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 337 | ONLY_ACTIVE_ARCH = YES; 338 | STRIP_INSTALLED_PRODUCT = NO; 339 | SYMROOT = "${SRCROOT}/../build"; 340 | }; 341 | name = Debug; 342 | }; 343 | B2CBD416FDAEB1EEFD87F5F40D8F9E19 /* Debug */ = { 344 | isa = XCBuildConfiguration; 345 | baseConfigurationReference = 39A985F2F0CA842CC568F97FAFFB7BD9 /* Pods-WebViewBridgeDemo.debug.xcconfig */; 346 | buildSettings = { 347 | ENABLE_STRICT_OBJC_MSGSEND = YES; 348 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 349 | MTL_ENABLE_DEBUG_INFO = YES; 350 | OTHER_LDFLAGS = ""; 351 | OTHER_LIBTOOLFLAGS = ""; 352 | PODS_ROOT = "$(SRCROOT)"; 353 | PRODUCT_NAME = "$(TARGET_NAME)"; 354 | SDKROOT = iphoneos; 355 | SKIP_INSTALL = YES; 356 | }; 357 | name = Debug; 358 | }; 359 | BD367D58E05FA23CD99F974D006ACC38 /* Debug */ = { 360 | isa = XCBuildConfiguration; 361 | baseConfigurationReference = 2B67F634AF56E551708EF9B7DCD55C3F /* WebViewJavascriptBridge-Private.xcconfig */; 362 | buildSettings = { 363 | ENABLE_STRICT_OBJC_MSGSEND = YES; 364 | GCC_PREFIX_HEADER = "Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch"; 365 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 366 | MTL_ENABLE_DEBUG_INFO = YES; 367 | OTHER_LDFLAGS = ""; 368 | OTHER_LIBTOOLFLAGS = ""; 369 | PRODUCT_NAME = "$(TARGET_NAME)"; 370 | SDKROOT = iphoneos; 371 | SKIP_INSTALL = YES; 372 | }; 373 | name = Debug; 374 | }; 375 | C4F7ACD39C53CA62C1FA599832284773 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | baseConfigurationReference = 45A48248024DC4650E4151EDCFF71F16 /* Pods-WebViewBridgeDemo.release.xcconfig */; 378 | buildSettings = { 379 | ENABLE_STRICT_OBJC_MSGSEND = YES; 380 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 381 | MTL_ENABLE_DEBUG_INFO = NO; 382 | OTHER_LDFLAGS = ""; 383 | OTHER_LIBTOOLFLAGS = ""; 384 | PODS_ROOT = "$(SRCROOT)"; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | SDKROOT = iphoneos; 387 | SKIP_INSTALL = YES; 388 | }; 389 | name = Release; 390 | }; 391 | C5A18280E9321A9268D1C80B7DA43967 /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ALWAYS_SEARCH_USER_PATHS = NO; 395 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 396 | CLANG_CXX_LIBRARY = "libc++"; 397 | CLANG_ENABLE_MODULES = YES; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | CLANG_WARN_BOOL_CONVERSION = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INT_CONVERSION = YES; 405 | CLANG_WARN_OBJC_ROOT_CLASS = YES; 406 | CLANG_WARN_UNREACHABLE_CODE = YES; 407 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 408 | COPY_PHASE_STRIP = YES; 409 | ENABLE_NS_ASSERTIONS = NO; 410 | GCC_C_LANGUAGE_STANDARD = gnu99; 411 | GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1"; 412 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 413 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 414 | GCC_WARN_UNDECLARED_SELECTOR = YES; 415 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 416 | GCC_WARN_UNUSED_FUNCTION = YES; 417 | GCC_WARN_UNUSED_VARIABLE = YES; 418 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 419 | STRIP_INSTALLED_PRODUCT = NO; 420 | SYMROOT = "${SRCROOT}/../build"; 421 | VALIDATE_PRODUCT = YES; 422 | }; 423 | name = Release; 424 | }; 425 | /* End XCBuildConfiguration section */ 426 | 427 | /* Begin XCConfigurationList section */ 428 | 14CA6CBC2A07FD0E37684C2E6C15704A /* Build configuration list for PBXNativeTarget "Pods-WebViewBridgeDemo" */ = { 429 | isa = XCConfigurationList; 430 | buildConfigurations = ( 431 | B2CBD416FDAEB1EEFD87F5F40D8F9E19 /* Debug */, 432 | C4F7ACD39C53CA62C1FA599832284773 /* Release */, 433 | ); 434 | defaultConfigurationIsVisible = 0; 435 | defaultConfigurationName = Release; 436 | }; 437 | 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { 438 | isa = XCConfigurationList; 439 | buildConfigurations = ( 440 | 8D1534490D941DCA47C62AC4314182AF /* Debug */, 441 | C5A18280E9321A9268D1C80B7DA43967 /* Release */, 442 | ); 443 | defaultConfigurationIsVisible = 0; 444 | defaultConfigurationName = Release; 445 | }; 446 | C4EFF457CC3A797CFBE7FC0FC2EC76A5 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | BD367D58E05FA23CD99F974D006ACC38 /* Debug */, 450 | 2A879E50B313B30B09DBA82035412944 /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | /* End XCConfigurationList section */ 456 | }; 457 | rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; 458 | } 459 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/Pods-WebViewBridgeDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 47 | 48 | 54 | 55 | 57 | 58 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/WebViewJavascriptBridge.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 47 | 48 | 54 | 55 | 57 | 58 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-WebViewBridgeDemo.xcscheme 8 | 9 | isShown 10 | 11 | 12 | WebViewJavascriptBridge.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 477CB162EF755578CADCDFAD4AA26874 21 | 22 | primary 23 | 24 | 25 | B5C58B7038FC798C8176028788947AB5 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-WebViewBridgeDemo/Pods-WebViewBridgeDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## WebViewJavascriptBridge 5 | 6 | Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec 7 | 8 | Permission is hereby granted, free of charge, to any person 9 | obtaining a copy of this software and associated documentation 10 | files (the "Software"), to deal in the Software without 11 | restriction, including without limitation the rights to use, 12 | copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the 14 | Software is furnished to do so, subject to the following 15 | conditions: 16 | 17 | The above copyright notice and this permission notice shall be 18 | included in all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | OTHER DEALINGS IN THE SOFTWARE. 28 | 29 | Generated by CocoaPods - http://cocoapods.org 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-WebViewBridgeDemo/Pods-WebViewBridgeDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec 18 | 19 | Permission is hereby granted, free of charge, to any person 20 | obtaining a copy of this software and associated documentation 21 | files (the "Software"), to deal in the Software without 22 | restriction, including without limitation the rights to use, 23 | copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | copies of the Software, and to permit persons to whom the 25 | Software is furnished to do so, subject to the following 26 | conditions: 27 | 28 | The above copyright notice and this permission notice shall be 29 | included in all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 32 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 33 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 34 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 35 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 36 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 37 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 38 | OTHER DEALINGS IN THE SOFTWARE. 39 | 40 | Title 41 | WebViewJavascriptBridge 42 | Type 43 | PSGroupSpecifier 44 | 45 | 46 | FooterText 47 | Generated by CocoaPods - http://cocoapods.org 48 | Title 49 | 50 | Type 51 | PSGroupSpecifier 52 | 53 | 54 | StringsTable 55 | Acknowledgements 56 | Title 57 | Acknowledgements 58 | 59 | 60 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-WebViewBridgeDemo/Pods-WebViewBridgeDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_WebViewBridgeDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_WebViewBridgeDemo 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-WebViewBridgeDemo/Pods-WebViewBridgeDemo-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 63 | if [[ "${ACTION}" == "install" ]]; then 64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 66 | fi 67 | rm -f "$RESOURCES_TO_COPY" 68 | 69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 70 | then 71 | case "${TARGETED_DEVICE_FAMILY}" in 72 | 1,2) 73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 74 | ;; 75 | 1) 76 | TARGET_DEVICE_ARGS="--target-device iphone" 77 | ;; 78 | 2) 79 | TARGET_DEVICE_ARGS="--target-device ipad" 80 | ;; 81 | *) 82 | TARGET_DEVICE_ARGS="--target-device mac" 83 | ;; 84 | esac 85 | 86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 88 | while read line; do 89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 90 | XCASSET_FILES+=("$line") 91 | fi 92 | done <<<"$OTHER_XCASSETS" 93 | 94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 95 | fi 96 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-WebViewBridgeDemo/Pods-WebViewBridgeDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WebViewJavascriptBridge" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/WebViewJavascriptBridge" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"WebViewJavascriptBridge" -framework "UIKit" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-WebViewBridgeDemo/Pods-WebViewBridgeDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WebViewJavascriptBridge" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/WebViewJavascriptBridge" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"WebViewJavascriptBridge" -framework "UIKit" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "WebViewJavascriptBridge.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/WebViewJavascriptBridge" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WebViewJavascriptBridge" 4 | OTHER_LDFLAGS = ${WEBVIEWJAVASCRIPTBRIDGE_OTHER_LDFLAGS} 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_WebViewJavascriptBridge : NSObject 3 | @end 4 | @implementation PodsDummy_WebViewJavascriptBridge 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.xcconfig: -------------------------------------------------------------------------------- 1 | WEBVIEWJAVASCRIPTBRIDGE_OTHER_LDFLAGS = -framework "UIKit" -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/README.md: -------------------------------------------------------------------------------- 1 | WebViewJavascriptBridge 2 | ======================= 3 | 4 | [![Build Status](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge.svg)](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge) 5 | 6 | An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews. 7 | 8 | Who uses WebViewJavascriptBridge? 9 | --------------------------------- 10 | WebViewJavascriptBridge is used by a range of companies and projects. This is a small and incomplete sample list: 11 | 12 | - [Facebook Messenger](https://www.facebook.com/mobile/messenger) 13 | - [Facebook Paper](https://facebook.com/paper) 14 | - [Yardsale](http://www.getyardsale.com/) 15 | - [EverTrue](http://www.evertrue.com/) 16 | - [Game Insight](http://www.game-insight.com/) 17 | - [Sush.io](http://www.sush.io) 18 | - [Imbed](http://imbed.github.io/) 19 | - [CareZone](https://carezone.com) 20 | - [Hemlig](http://www.hemlig.co) 21 | - [Altralogica](http://www.altralogica.it) 22 | - [鼎盛中华](https://itunes.apple.com/us/app/ding-sheng-zhong-hua/id537273940?mt=8) 23 | - [FRIL](https://fril.jp) 24 | - [留白·WHITE](http://liubaiapp.com) 25 | 26 | Installation (iOS & OSX) 27 | ------------------------ 28 | 29 | ### Installation with CocoaPods 30 | Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: 31 | 32 | ```ruby 33 | `pod 'WebViewJavascriptBridge', '~> 5.0'` 34 | ``` 35 | 36 | ### Manual installation 37 | 38 | Drag the `WebViewJavascriptBridge` folder into your project. 39 | 40 | In the dialog that appears, uncheck "Copy items into destination group's folder" and select "Create groups for any folders". 41 | 42 | Examples 43 | -------- 44 | 45 | See the `Example Apps/` folder. Open either the iOS or OSX project and hit run to see it in action. 46 | 47 | To use a WebViewJavascriptBridge in your own project: 48 | 49 | Usage 50 | ----- 51 | 52 | 1) Import the header file and declare an ivar property: 53 | 54 | ```objc 55 | #import "WebViewJavascriptBridge.h" 56 | ``` 57 | 58 | ... 59 | 60 | ```objc 61 | @property WebViewJavascriptBridge* bridge; 62 | ``` 63 | 64 | 2) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX): 65 | 66 | ```objc 67 | self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; 68 | ``` 69 | 70 | 3) Register a handler in ObjC, and call a JS handler: 71 | 72 | ```objc 73 | [self.bridge registerHandler:@"ObjC Echo" handler:^(id data, WVJBResponseCallback responseCallback) { 74 | NSLog(@"ObjC Echo called with: %@", data); 75 | responseCallback(data); 76 | }]; 77 | [self.bridge callHandler:@"JS Echo" responseCallback:^(id responseData) { 78 | NSLog(@"ObjC received response: %@", responseData); 79 | }]; 80 | ``` 81 | 82 | 4) Copy and paste `setupWebViewJavascriptBridge` into your JS: 83 | 84 | ```javascript 85 | function setupWebViewJavascriptBridge(callback) { 86 | if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } 87 | if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } 88 | window.WVJBCallbacks = [callback]; 89 | var WVJBIframe = document.createElement('iframe'); 90 | WVJBIframe.style.display = 'none'; 91 | WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; 92 | document.documentElement.appendChild(WVJBIframe); 93 | setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) 94 | } 95 | ``` 96 | 97 | 5) Finally, call `setupWebViewJavascriptBridge` and then use the bridge to register handlers and call ObjC handlers: 98 | 99 | ```javascript 100 | setupWebViewJavascriptBridge(function(bridge) { 101 | 102 | /* Initialize your app here */ 103 | 104 | bridge.registerHandler('JS Echo', function(data, responseCallback) { 105 | console.log("JS Echo called with:", data) 106 | responseCallback(data) 107 | }) 108 | bridge.callHandler('ObjC Echo', function responseCallback(responseData) { 109 | console.log("JS received response:", responseData) 110 | }) 111 | }) 112 | ``` 113 | 114 | WKWebView Support (iOS 8+ & OS 10.10+) 115 | -------------------------------------- 116 | 117 | (WARNING: WKWebView still has [bugs and missing network APIs.](https://github.com/ShingoFukuyama/WKWebViewTips/blob/master/README.md) It may not be a simple drop-in replacement). 118 | 119 | WebViewJavascriptBridge supports [WKWebView](http://nshipster.com/wkwebkit/) for iOS 8 and OSX Yosemite. In order to use WKWebView you need to instantiate the `WKWebViewJavascriptBridge`. The rest of the `WKWebViewJavascriptBridge` API is the same as `WebViewJavascriptBridge`. 120 | 121 | 1) Import the header file: 122 | 123 | ```objc 124 | #import "WKWebViewJavascriptBridge.h" 125 | ``` 126 | 127 | 2) Instantiate WKWebViewJavascriptBridge and with a WKWebView object 128 | 129 | ```objc 130 | WKWebViewJavascriptBridge* bridge = [WKWebViewJavascriptBridge bridgeForWebView:webView]; 131 | ``` 132 | 133 | Contributors & Forks 134 | -------------------- 135 | Contributors: https://github.com/marcuswestin/WebViewJavascriptBridge/graphs/contributors 136 | 137 | Forks: https://github.com/marcuswestin/WebViewJavascriptBridge/network/members 138 | 139 | API Reference 140 | ------------- 141 | 142 | ### ObjC API 143 | 144 | ##### `[WebViewJavascriptBridge bridgeForWebView:(UIWebView/WebView*)webview` 145 | 146 | Create a javascript bridge for the given web view. 147 | 148 | Example: 149 | 150 | ```objc 151 | [WebViewJavascriptBridge bridgeForWebView:webView]; 152 | ``` 153 | 154 | ##### `[bridge registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler]` 155 | 156 | Register a handler called `handlerName`. The javascript can then call this handler with `WebViewJavascriptBridge.callHandler("handlerName")`. 157 | 158 | Example: 159 | 160 | ```objc 161 | [self.bridge registerHandler:@"getScreenHeight" handler:^(id data, WVJBResponseCallback responseCallback) { 162 | responseCallback([NSNumber numberWithInt:[UIScreen mainScreen].bounds.size.height]); 163 | }]; 164 | [self.bridge registerHandler:@"log" handler:^(id data, WVJBResponseCallback responseCallback) { 165 | NSLog(@"Log: %@", data); 166 | }]; 167 | 168 | ``` 169 | 170 | ##### `[bridge callHandler:(NSString*)handlerName data:(id)data]` 171 | ##### `[bridge callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)callback]` 172 | 173 | Call the javascript handler called `handlerName`. If a `responseCallback` block is given the javascript handler can respond. 174 | 175 | Example: 176 | 177 | ```objc 178 | [self.bridge callHandler:@"showAlert" data:@"Hi from ObjC to JS!"]; 179 | [self.bridge callHandler:@"getCurrentPageUrl" data:nil responseCallback:^(id responseData) { 180 | NSLog(@"Current UIWebView page URL is: %@", responseData); 181 | }]; 182 | ``` 183 | 184 | #### `[bridge setWebViewDelegate:UIWebViewDelegate*)webViewDelegate]` 185 | 186 | Optionally, set a `UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html). 187 | 188 | 189 | 190 | 191 | ### Javascript API 192 | 193 | ##### `bridge.registerHandler("handlerName", function(responseData) { ... })` 194 | 195 | Register a handler called `handlerName`. The ObjC can then call this handler with `[bridge callHandler:"handlerName" data:@"Foo"]` and `[bridge callHandler:"handlerName" data:@"Foo" responseCallback:^(id responseData) { ... }]` 196 | 197 | Example: 198 | 199 | ```javascript 200 | bridge.registerHandler("showAlert", function(data) { alert(data) }) 201 | bridge.registerHandler("getCurrentPageUrl", function(data, responseCallback) { 202 | responseCallback(document.location.toString()) 203 | }) 204 | ``` 205 | 206 | 207 | ##### `bridge.callHander("handlerName", data)` 208 | ##### `bridge.callHander("handlerName", data, function responseCallback(responseData) { ... })` 209 | 210 | Call an ObjC handler called `handlerName`. If a `responseCallback` function is given the ObjC handler can respond. 211 | 212 | Example: 213 | 214 | ```javascript 215 | bridge.callHandler("Log", "Foo") 216 | bridge.callHandler("getScreenHeight", null, function(response) { 217 | alert('Screen height:' + response) 218 | }) 219 | ``` 220 | -------------------------------------------------------------------------------- /Pods/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 | 30 | @end 31 | 32 | #endif -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebViewJavascriptBridge.m 3 | // 4 | // Created by @LokiMeyburg on 10/15/14. 5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved. 6 | // 7 | 8 | 9 | #import "WKWebViewJavascriptBridge.h" 10 | 11 | #if defined(supportsWKWebKit) 12 | 13 | @implementation WKWebViewJavascriptBridge { 14 | WKWebView* _webView; 15 | id _webViewDelegate; 16 | long _uniqueId; 17 | WebViewJavascriptBridgeBase *_base; 18 | } 19 | 20 | /* API 21 | *****/ 22 | 23 | + (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } 24 | 25 | + (instancetype)bridgeForWebView:(WKWebView*)webView { 26 | WKWebViewJavascriptBridge* bridge = [[self alloc] init]; 27 | [bridge _setupInstance:webView]; 28 | [bridge reset]; 29 | return bridge; 30 | } 31 | 32 | - (void)send:(id)data { 33 | [self send:data responseCallback:nil]; 34 | } 35 | 36 | - (void)send:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 37 | [_base sendData:data responseCallback:responseCallback handlerName:nil]; 38 | } 39 | 40 | - (void)callHandler:(NSString *)handlerName { 41 | [self callHandler:handlerName data:nil responseCallback:nil]; 42 | } 43 | 44 | - (void)callHandler:(NSString *)handlerName data:(id)data { 45 | [self callHandler:handlerName data:data responseCallback:nil]; 46 | } 47 | 48 | - (void)callHandler:(NSString *)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 49 | [_base sendData:data responseCallback:responseCallback handlerName:handlerName]; 50 | } 51 | 52 | - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { 53 | _base.messageHandlers[handlerName] = [handler copy]; 54 | } 55 | 56 | - (void)reset { 57 | [_base reset]; 58 | } 59 | 60 | - (void)setWebViewDelegate:(id)webViewDelegate { 61 | _webViewDelegate = webViewDelegate; 62 | } 63 | 64 | /* Internals 65 | ***********/ 66 | 67 | - (void)dealloc { 68 | _base = nil; 69 | _webView = nil; 70 | _webViewDelegate = nil; 71 | _webView.navigationDelegate = nil; 72 | } 73 | 74 | 75 | /* WKWebView Specific Internals 76 | ******************************/ 77 | 78 | - (void) _setupInstance:(WKWebView*)webView { 79 | _webView = webView; 80 | _webView.navigationDelegate = self; 81 | _base = [[WebViewJavascriptBridgeBase alloc] init]; 82 | _base.delegate = self; 83 | } 84 | 85 | 86 | - (void)WKFlushMessageQueue { 87 | [_webView evaluateJavaScript:[_base webViewJavascriptFetchQueyCommand] completionHandler:^(NSString* result, NSError* error) { 88 | if (error != nil) { 89 | NSLog(@"WebViewJavascriptBridge: WARNING: Error when trying to fetch data from WKWebView: %@", error); 90 | } 91 | [_base flushMessageQueue:result]; 92 | }]; 93 | } 94 | 95 | - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 96 | { 97 | if (webView != _webView) { return; } 98 | 99 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 100 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFinishNavigation:)]) { 101 | [strongDelegate webView:webView didFinishNavigation:navigation]; 102 | } 103 | } 104 | 105 | 106 | - (void)webView:(WKWebView *)webView 107 | decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction 108 | decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 109 | if (webView != _webView) { return; } 110 | NSURL *url = navigationAction.request.URL; 111 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 112 | 113 | if ([_base isCorrectProcotocolScheme:url]) { 114 | if ([_base isBridgeLoadedURL:url]) { 115 | [_base injectJavascriptFile]; 116 | } else if ([_base isQueueMessageURL:url]) { 117 | [self WKFlushMessageQueue]; 118 | } else { 119 | [_base logUnkownMessage:url]; 120 | } 121 | decisionHandler(WKNavigationActionPolicyCancel); 122 | } 123 | 124 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { 125 | [_webViewDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler]; 126 | } else { 127 | decisionHandler(WKNavigationActionPolicyAllow); 128 | } 129 | } 130 | 131 | - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { 132 | if (webView != _webView) { return; } 133 | 134 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 135 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didStartProvisionalNavigation:)]) { 136 | [strongDelegate webView:webView didStartProvisionalNavigation:navigation]; 137 | } 138 | } 139 | 140 | 141 | - (void)webView:(WKWebView *)webView 142 | didFailNavigation:(WKNavigation *)navigation 143 | withError:(NSError *)error { 144 | if (webView != _webView) { return; } 145 | 146 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 147 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailNavigation:withError:)]) { 148 | [strongDelegate webView:webView didFailNavigation:navigation withError:error]; 149 | } 150 | } 151 | 152 | - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { 153 | if (webView != _webView) { return; } 154 | 155 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 156 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailProvisionalNavigation:withError:)]) { 157 | [strongDelegate webView:webView didFailProvisionalNavigation:navigation withError:error]; 158 | } 159 | } 160 | 161 | - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand 162 | { 163 | [_webView evaluateJavaScript:javascriptCommand completionHandler:nil]; 164 | return NULL; 165 | } 166 | 167 | 168 | 169 | @end 170 | 171 | 172 | #endif 173 | -------------------------------------------------------------------------------- /Pods/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 | @end 38 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridge.m 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 "WebViewJavascriptBridge.h" 10 | 11 | #if __has_feature(objc_arc_weak) 12 | #define WVJB_WEAK __weak 13 | #else 14 | #define WVJB_WEAK __unsafe_unretained 15 | #endif 16 | 17 | @implementation WebViewJavascriptBridge { 18 | WVJB_WEAK WVJB_WEBVIEW_TYPE* _webView; 19 | WVJB_WEAK id _webViewDelegate; 20 | long _uniqueId; 21 | WebViewJavascriptBridgeBase *_base; 22 | } 23 | 24 | /* API 25 | *****/ 26 | 27 | + (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } 28 | + (void)setLogMaxLength:(int)length { [WebViewJavascriptBridgeBase setLogMaxLength:length]; } 29 | 30 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView { 31 | WebViewJavascriptBridge* bridge = [[self alloc] init]; 32 | [bridge _platformSpecificSetup:webView]; 33 | return bridge; 34 | } 35 | 36 | - (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate { 37 | _webViewDelegate = webViewDelegate; 38 | } 39 | 40 | - (void)send:(id)data { 41 | [self send:data responseCallback:nil]; 42 | } 43 | 44 | - (void)send:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 45 | [_base sendData:data responseCallback:responseCallback handlerName:nil]; 46 | } 47 | 48 | - (void)callHandler:(NSString *)handlerName { 49 | [self callHandler:handlerName data:nil responseCallback:nil]; 50 | } 51 | 52 | - (void)callHandler:(NSString *)handlerName data:(id)data { 53 | [self callHandler:handlerName data:data responseCallback:nil]; 54 | } 55 | 56 | - (void)callHandler:(NSString *)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 57 | [_base sendData:data responseCallback:responseCallback handlerName:handlerName]; 58 | } 59 | 60 | - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { 61 | _base.messageHandlers[handlerName] = [handler copy]; 62 | } 63 | 64 | /* Platform agnostic internals 65 | *****************************/ 66 | 67 | - (void)dealloc { 68 | [self _platformSpecificDealloc]; 69 | _base = nil; 70 | _webView = nil; 71 | _webViewDelegate = nil; 72 | } 73 | 74 | - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand 75 | { 76 | return [_webView stringByEvaluatingJavaScriptFromString:javascriptCommand]; 77 | } 78 | 79 | /* Platform specific internals: OSX 80 | **********************************/ 81 | #if defined WVJB_PLATFORM_OSX 82 | 83 | - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { 84 | _webView = webView; 85 | 86 | _webView.policyDelegate = self; 87 | 88 | _base = [[WebViewJavascriptBridgeBase alloc] init]; 89 | _base.delegate = self; 90 | } 91 | 92 | - (void) _platformSpecificDealloc { 93 | _webView.policyDelegate = nil; 94 | } 95 | 96 | - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener 97 | { 98 | if (webView != _webView) { return; } 99 | 100 | NSURL *url = [request URL]; 101 | if ([_base isCorrectProcotocolScheme:url]) { 102 | if ([_base isBridgeLoadedURL:url]) { 103 | [_base injectJavascriptFile]; 104 | } else if ([_base isQueueMessageURL:url]) { 105 | NSString *messageQueueString = [self _evaluateJavascript:[_base webViewJavascriptFetchQueyCommand]]; 106 | [_base flushMessageQueue:messageQueueString]; 107 | } else { 108 | [_base logUnkownMessage:url]; 109 | } 110 | [listener ignore]; 111 | } else if (_webViewDelegate && [_webViewDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)]) { 112 | [_webViewDelegate webView:webView decidePolicyForNavigationAction:actionInformation request:request frame:frame decisionListener:listener]; 113 | } else { 114 | [listener use]; 115 | } 116 | } 117 | 118 | 119 | 120 | /* Platform specific internals: iOS 121 | **********************************/ 122 | #elif defined WVJB_PLATFORM_IOS 123 | 124 | - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { 125 | _webView = webView; 126 | _webView.delegate = self; 127 | _base = [[WebViewJavascriptBridgeBase alloc] init]; 128 | _base.delegate = self; 129 | } 130 | 131 | - (void) _platformSpecificDealloc { 132 | _webView.delegate = nil; 133 | } 134 | 135 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 136 | if (webView != _webView) { return; } 137 | 138 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 139 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 140 | [strongDelegate webViewDidFinishLoad:webView]; 141 | } 142 | } 143 | 144 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { 145 | if (webView != _webView) { return; } 146 | 147 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 148 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) { 149 | [strongDelegate webView:webView didFailLoadWithError:error]; 150 | } 151 | } 152 | 153 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 154 | if (webView != _webView) { return YES; } 155 | NSURL *url = [request URL]; 156 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 157 | if ([_base isCorrectProcotocolScheme:url]) { 158 | if ([_base isBridgeLoadedURL:url]) { 159 | [_base injectJavascriptFile]; 160 | } else if ([_base isQueueMessageURL:url]) { 161 | NSString *messageQueueString = [self _evaluateJavascript:[_base webViewJavascriptFetchQueyCommand]]; 162 | [_base flushMessageQueue:messageQueueString]; 163 | } else { 164 | [_base logUnkownMessage:url]; 165 | } 166 | return NO; 167 | } else if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) { 168 | return [strongDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; 169 | } else { 170 | return YES; 171 | } 172 | } 173 | 174 | - (void)webViewDidStartLoad:(UIWebView *)webView { 175 | if (webView != _webView) { return; } 176 | 177 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 178 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 179 | [strongDelegate webViewDidStartLoad:webView]; 180 | } 181 | } 182 | 183 | #endif 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /Pods/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 (assign) 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 | 44 | @end -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridgeBase.m 3 | // 4 | // Created by @LokiMeyburg on 10/15/14. 5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "WebViewJavascriptBridgeBase.h" 10 | #import "WebViewJavascriptBridge_JS.h" 11 | 12 | @implementation WebViewJavascriptBridgeBase { 13 | id _webViewDelegate; 14 | long _uniqueId; 15 | } 16 | 17 | static bool logging = false; 18 | static int logMaxLength = 500; 19 | 20 | + (void)enableLogging { logging = true; } 21 | + (void)setLogMaxLength:(int)length { logMaxLength = length;} 22 | 23 | -(id)init { 24 | self = [super init]; 25 | self.messageHandlers = [NSMutableDictionary dictionary]; 26 | self.startupMessageQueue = [NSMutableArray array]; 27 | self.responseCallbacks = [NSMutableDictionary dictionary]; 28 | _uniqueId = 0; 29 | return(self); 30 | } 31 | 32 | - (void)dealloc { 33 | self.startupMessageQueue = nil; 34 | self.responseCallbacks = nil; 35 | self.messageHandlers = nil; 36 | } 37 | 38 | - (void)reset { 39 | self.startupMessageQueue = [NSMutableArray array]; 40 | self.responseCallbacks = [NSMutableDictionary dictionary]; 41 | _uniqueId = 0; 42 | } 43 | 44 | - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName { 45 | NSMutableDictionary* message = [NSMutableDictionary dictionary]; 46 | 47 | if (data) { 48 | message[@"data"] = data; 49 | } 50 | 51 | if (responseCallback) { 52 | NSString* callbackId = [NSString stringWithFormat:@"objc_cb_%ld", ++_uniqueId]; 53 | self.responseCallbacks[callbackId] = [responseCallback copy]; 54 | message[@"callbackId"] = callbackId; 55 | } 56 | 57 | if (handlerName) { 58 | message[@"handlerName"] = handlerName; 59 | } 60 | [self _queueMessage:message]; 61 | } 62 | 63 | - (void)flushMessageQueue:(NSString *)messageQueueString{ 64 | if (messageQueueString == nil || messageQueueString.length == 0) { 65 | NSLog(@"WebViewJavascriptBridge: WARNING: ObjC got nil while fetching the message queue JSON from webview. This can happen if the WebViewJavascriptBridge JS is not currently present in the webview, e.g if the webview just loaded a new page."); 66 | return; 67 | } 68 | 69 | id messages = [self _deserializeMessageJSON:messageQueueString]; 70 | for (WVJBMessage* message in messages) { 71 | if (![message isKindOfClass:[WVJBMessage class]]) { 72 | NSLog(@"WebViewJavascriptBridge: WARNING: Invalid %@ received: %@", [message class], message); 73 | continue; 74 | } 75 | [self _log:@"RCVD" json:message]; 76 | 77 | NSString* responseId = message[@"responseId"]; 78 | if (responseId) { 79 | WVJBResponseCallback responseCallback = _responseCallbacks[responseId]; 80 | responseCallback(message[@"responseData"]); 81 | [self.responseCallbacks removeObjectForKey:responseId]; 82 | } else { 83 | WVJBResponseCallback responseCallback = NULL; 84 | NSString* callbackId = message[@"callbackId"]; 85 | if (callbackId) { 86 | responseCallback = ^(id responseData) { 87 | if (responseData == nil) { 88 | responseData = [NSNull null]; 89 | } 90 | 91 | WVJBMessage* msg = @{ @"responseId":callbackId, @"responseData":responseData }; 92 | [self _queueMessage:msg]; 93 | }; 94 | } else { 95 | responseCallback = ^(id ignoreResponseData) { 96 | // Do nothing 97 | }; 98 | } 99 | 100 | WVJBHandler handler = self.messageHandlers[message[@"handlerName"]]; 101 | 102 | if (!handler) { 103 | NSLog(@"WVJBNoHandlerException, No handler for message from JS: %@", message); 104 | continue; 105 | } 106 | 107 | handler(message[@"data"], responseCallback); 108 | } 109 | } 110 | } 111 | 112 | - (void)injectJavascriptFile { 113 | NSString *js = WebViewJavascriptBridge_js(); 114 | [self _evaluateJavascript:js]; 115 | if (self.startupMessageQueue) { 116 | NSArray* queue = self.startupMessageQueue; 117 | self.startupMessageQueue = nil; 118 | for (id queuedMessage in queue) { 119 | [self _dispatchMessage:queuedMessage]; 120 | } 121 | } 122 | } 123 | 124 | -(BOOL)isCorrectProcotocolScheme:(NSURL*)url { 125 | if([[url scheme] isEqualToString:kCustomProtocolScheme]){ 126 | return YES; 127 | } else { 128 | return NO; 129 | } 130 | } 131 | 132 | -(BOOL)isQueueMessageURL:(NSURL*)url { 133 | if([[url host] isEqualToString:kQueueHasMessage]){ 134 | return YES; 135 | } else { 136 | return NO; 137 | } 138 | } 139 | 140 | -(BOOL)isBridgeLoadedURL:(NSURL*)url { 141 | return ([[url scheme] isEqualToString:kCustomProtocolScheme] && [[url host] isEqualToString:kBridgeLoaded]); 142 | } 143 | 144 | -(void)logUnkownMessage:(NSURL*)url { 145 | NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@://%@", kCustomProtocolScheme, [url path]); 146 | } 147 | 148 | -(NSString *)webViewJavascriptCheckCommand { 149 | return @"typeof WebViewJavascriptBridge == \'object\';"; 150 | } 151 | 152 | -(NSString *)webViewJavascriptFetchQueyCommand { 153 | return @"WebViewJavascriptBridge._fetchQueue();"; 154 | } 155 | 156 | // Private 157 | // ------------------------------------------- 158 | 159 | - (void) _evaluateJavascript:(NSString *)javascriptCommand { 160 | [self.delegate _evaluateJavascript:javascriptCommand]; 161 | } 162 | 163 | - (void)_queueMessage:(WVJBMessage*)message { 164 | if (self.startupMessageQueue) { 165 | [self.startupMessageQueue addObject:message]; 166 | } else { 167 | [self _dispatchMessage:message]; 168 | } 169 | } 170 | 171 | - (void)_dispatchMessage:(WVJBMessage*)message { 172 | NSString *messageJSON = [self _serializeMessage:message pretty:NO]; 173 | [self _log:@"SEND" json:messageJSON]; 174 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]; 175 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; 176 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\'" withString:@"\\\'"]; 177 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; 178 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\r" withString:@"\\r"]; 179 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\f" withString:@"\\f"]; 180 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2028" withString:@"\\u2028"]; 181 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2029" withString:@"\\u2029"]; 182 | 183 | NSString* javascriptCommand = [NSString stringWithFormat:@"WebViewJavascriptBridge._handleMessageFromObjC('%@');", messageJSON]; 184 | if ([[NSThread currentThread] isMainThread]) { 185 | [self _evaluateJavascript:javascriptCommand]; 186 | 187 | } else { 188 | dispatch_sync(dispatch_get_main_queue(), ^{ 189 | [self _evaluateJavascript:javascriptCommand]; 190 | }); 191 | } 192 | } 193 | 194 | - (NSString *)_serializeMessage:(id)message pretty:(BOOL)pretty{ 195 | return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:message options:(NSJSONWritingOptions)(pretty ? NSJSONWritingPrettyPrinted : 0) error:nil] encoding:NSUTF8StringEncoding]; 196 | } 197 | 198 | - (NSArray*)_deserializeMessageJSON:(NSString *)messageJSON { 199 | return [NSJSONSerialization JSONObjectWithData:[messageJSON dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil]; 200 | } 201 | 202 | - (void)_log:(NSString *)action json:(id)json { 203 | if (!logging) { return; } 204 | if (![json isKindOfClass:[NSString class]]) { 205 | json = [self _serializeMessage:json pretty:YES]; 206 | } 207 | if ([json length] > logMaxLength) { 208 | NSLog(@"WVJB %@: %@ [...]", action, [json substringToIndex:logMaxLength]); 209 | } else { 210 | NSLog(@"WVJB %@: %@", action, json); 211 | } 212 | } 213 | 214 | @end -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSString * WebViewJavascriptBridge_js(); -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m: -------------------------------------------------------------------------------- 1 | // This file contains the source for the Javascript side of the 2 | // WebViewJavascriptBridge. It is plaintext, but converted to an NSString 3 | // via some preprocessor tricks. 4 | // 5 | // Previous implementations of WebViewJavascriptBridge loaded the javascript source 6 | // from a resource. This worked fine for app developers, but library developers who 7 | // included the bridge into their library, awkwardly had to ask consumers of their 8 | // library to include the resource, violating their encapsulation. By including the 9 | // Javascript as a string resource, the encapsulation of the library is maintained. 10 | 11 | #import "WebViewJavascriptBridge_JS.h" 12 | 13 | NSString * WebViewJavascriptBridge_js() { 14 | #define __wvjb_js_func__(x) #x 15 | 16 | // BEGIN preprocessorJSCode 17 | static NSString * preprocessorJSCode = @__wvjb_js_func__( 18 | ;(function() { 19 | if (window.WebViewJavascriptBridge) { 20 | return; 21 | } 22 | window.WebViewJavascriptBridge = { 23 | registerHandler: registerHandler, 24 | callHandler: callHandler, 25 | _fetchQueue: _fetchQueue, 26 | _handleMessageFromObjC: _handleMessageFromObjC 27 | }; 28 | 29 | var messagingIframe; 30 | var sendMessageQueue = []; 31 | var messageHandlers = {}; 32 | 33 | var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; 34 | var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'; 35 | 36 | var responseCallbacks = {}; 37 | var uniqueId = 1; 38 | 39 | function registerHandler(handlerName, handler) { 40 | messageHandlers[handlerName] = handler; 41 | } 42 | 43 | function callHandler(handlerName, data, responseCallback) { 44 | if (arguments.length == 2 && typeof data == 'function') { 45 | responseCallback = data; 46 | data = null; 47 | } 48 | _doSend({ handlerName:handlerName, data:data }, responseCallback); 49 | } 50 | 51 | function _doSend(message, responseCallback) { 52 | if (responseCallback) { 53 | var callbackId = 'cb_'+(uniqueId++)+'_'+new Date().getTime(); 54 | responseCallbacks[callbackId] = responseCallback; 55 | message['callbackId'] = callbackId; 56 | } 57 | sendMessageQueue.push(message); 58 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; 59 | } 60 | 61 | function _fetchQueue() { 62 | var messageQueueString = JSON.stringify(sendMessageQueue); 63 | sendMessageQueue = []; 64 | return messageQueueString; 65 | } 66 | 67 | function _dispatchMessageFromObjC(messageJSON) { 68 | setTimeout(function _timeoutDispatchMessageFromObjC() { 69 | var message = JSON.parse(messageJSON); 70 | var messageHandler; 71 | var responseCallback; 72 | 73 | if (message.responseId) { 74 | responseCallback = responseCallbacks[message.responseId]; 75 | if (!responseCallback) { 76 | return; 77 | } 78 | responseCallback(message.responseData); 79 | delete responseCallbacks[message.responseId]; 80 | } else { 81 | if (message.callbackId) { 82 | var callbackResponseId = message.callbackId; 83 | responseCallback = function(responseData) { 84 | _doSend({ responseId:callbackResponseId, responseData:responseData }); 85 | }; 86 | } 87 | 88 | var handler = messageHandlers[message.handlerName]; 89 | try { 90 | handler(message.data, responseCallback); 91 | } catch(exception) { 92 | console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception); 93 | } 94 | if (!handler) { 95 | console.log("WebViewJavascriptBridge: WARNING: no handler for message from ObjC:", message); 96 | } 97 | } 98 | }); 99 | } 100 | 101 | function _handleMessageFromObjC(messageJSON) { 102 | _dispatchMessageFromObjC(messageJSON); 103 | } 104 | 105 | messagingIframe = document.createElement('iframe'); 106 | messagingIframe.style.display = 'none'; 107 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; 108 | document.documentElement.appendChild(messagingIframe); 109 | 110 | setTimeout(_callWVJBCallbacks, 0); 111 | function _callWVJBCallbacks() { 112 | var callbacks = window.WVJBCallbacks; 113 | delete window.WVJBCallbacks; 114 | for (var i=0; i /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 331 | showEnvVarsInLog = 0; 332 | }; 333 | /* End PBXShellScriptBuildPhase section */ 334 | 335 | /* Begin PBXSourcesBuildPhase section */ 336 | 692FC3171C8F99ED00D2799D /* Sources */ = { 337 | isa = PBXSourcesBuildPhase; 338 | buildActionMask = 2147483647; 339 | files = ( 340 | 692FC3261C8F99ED00D2799D /* ViewController.m in Sources */, 341 | 692FC3231C8F99ED00D2799D /* AppDelegate.m in Sources */, 342 | 692FC3201C8F99ED00D2799D /* main.m in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | 692FC3301C8F99ED00D2799D /* Sources */ = { 347 | isa = PBXSourcesBuildPhase; 348 | buildActionMask = 2147483647; 349 | files = ( 350 | 692FC3391C8F99ED00D2799D /* WebViewBridgeDemoTests.m in Sources */, 351 | ); 352 | runOnlyForDeploymentPostprocessing = 0; 353 | }; 354 | 692FC33B1C8F99ED00D2799D /* Sources */ = { 355 | isa = PBXSourcesBuildPhase; 356 | buildActionMask = 2147483647; 357 | files = ( 358 | 692FC3441C8F99ED00D2799D /* WebViewBridgeDemoUITests.m in Sources */, 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | /* End PBXSourcesBuildPhase section */ 363 | 364 | /* Begin PBXTargetDependency section */ 365 | 692FC3361C8F99ED00D2799D /* PBXTargetDependency */ = { 366 | isa = PBXTargetDependency; 367 | target = 692FC31A1C8F99ED00D2799D /* WebViewBridgeDemo */; 368 | targetProxy = 692FC3351C8F99ED00D2799D /* PBXContainerItemProxy */; 369 | }; 370 | 692FC3411C8F99ED00D2799D /* PBXTargetDependency */ = { 371 | isa = PBXTargetDependency; 372 | target = 692FC31A1C8F99ED00D2799D /* WebViewBridgeDemo */; 373 | targetProxy = 692FC3401C8F99ED00D2799D /* PBXContainerItemProxy */; 374 | }; 375 | /* End PBXTargetDependency section */ 376 | 377 | /* Begin PBXVariantGroup section */ 378 | 692FC3271C8F99ED00D2799D /* Main.storyboard */ = { 379 | isa = PBXVariantGroup; 380 | children = ( 381 | 692FC3281C8F99ED00D2799D /* Base */, 382 | ); 383 | name = Main.storyboard; 384 | sourceTree = ""; 385 | }; 386 | 692FC32C1C8F99ED00D2799D /* LaunchScreen.storyboard */ = { 387 | isa = PBXVariantGroup; 388 | children = ( 389 | 692FC32D1C8F99ED00D2799D /* Base */, 390 | ); 391 | name = LaunchScreen.storyboard; 392 | sourceTree = ""; 393 | }; 394 | /* End PBXVariantGroup section */ 395 | 396 | /* Begin XCBuildConfiguration section */ 397 | 692FC3461C8F99ED00D2799D /* Debug */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ALWAYS_SEARCH_USER_PATHS = NO; 401 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 402 | CLANG_CXX_LIBRARY = "libc++"; 403 | CLANG_ENABLE_MODULES = YES; 404 | CLANG_ENABLE_OBJC_ARC = YES; 405 | CLANG_WARN_BOOL_CONVERSION = YES; 406 | CLANG_WARN_CONSTANT_CONVERSION = YES; 407 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 408 | CLANG_WARN_EMPTY_BODY = YES; 409 | CLANG_WARN_ENUM_CONVERSION = YES; 410 | CLANG_WARN_INT_CONVERSION = YES; 411 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 412 | CLANG_WARN_UNREACHABLE_CODE = YES; 413 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 414 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 415 | COPY_PHASE_STRIP = NO; 416 | DEBUG_INFORMATION_FORMAT = dwarf; 417 | ENABLE_STRICT_OBJC_MSGSEND = YES; 418 | ENABLE_TESTABILITY = YES; 419 | GCC_C_LANGUAGE_STANDARD = gnu99; 420 | GCC_DYNAMIC_NO_PIC = NO; 421 | GCC_NO_COMMON_BLOCKS = YES; 422 | GCC_OPTIMIZATION_LEVEL = 0; 423 | GCC_PREPROCESSOR_DEFINITIONS = ( 424 | "DEBUG=1", 425 | "$(inherited)", 426 | ); 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 434 | MTL_ENABLE_DEBUG_INFO = YES; 435 | ONLY_ACTIVE_ARCH = YES; 436 | SDKROOT = iphoneos; 437 | }; 438 | name = Debug; 439 | }; 440 | 692FC3471C8F99ED00D2799D /* Release */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ALWAYS_SEARCH_USER_PATHS = NO; 444 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 445 | CLANG_CXX_LIBRARY = "libc++"; 446 | CLANG_ENABLE_MODULES = YES; 447 | CLANG_ENABLE_OBJC_ARC = YES; 448 | CLANG_WARN_BOOL_CONVERSION = YES; 449 | CLANG_WARN_CONSTANT_CONVERSION = YES; 450 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 451 | CLANG_WARN_EMPTY_BODY = YES; 452 | CLANG_WARN_ENUM_CONVERSION = YES; 453 | CLANG_WARN_INT_CONVERSION = YES; 454 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 455 | CLANG_WARN_UNREACHABLE_CODE = YES; 456 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 457 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 458 | COPY_PHASE_STRIP = NO; 459 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 460 | ENABLE_NS_ASSERTIONS = NO; 461 | ENABLE_STRICT_OBJC_MSGSEND = YES; 462 | GCC_C_LANGUAGE_STANDARD = gnu99; 463 | GCC_NO_COMMON_BLOCKS = YES; 464 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 465 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 466 | GCC_WARN_UNDECLARED_SELECTOR = YES; 467 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 468 | GCC_WARN_UNUSED_FUNCTION = YES; 469 | GCC_WARN_UNUSED_VARIABLE = YES; 470 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 471 | MTL_ENABLE_DEBUG_INFO = NO; 472 | SDKROOT = iphoneos; 473 | VALIDATE_PRODUCT = YES; 474 | }; 475 | name = Release; 476 | }; 477 | 692FC3491C8F99ED00D2799D /* Debug */ = { 478 | isa = XCBuildConfiguration; 479 | baseConfigurationReference = BBC7D247C84703CAF1242344 /* Pods-WebViewBridgeDemo.debug.xcconfig */; 480 | buildSettings = { 481 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 482 | INFOPLIST_FILE = WebViewBridgeDemo/Info.plist; 483 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 484 | PRODUCT_BUNDLE_IDENTIFIER = com.huangyibiao.WebViewBridgeDemo; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | }; 487 | name = Debug; 488 | }; 489 | 692FC34A1C8F99ED00D2799D /* Release */ = { 490 | isa = XCBuildConfiguration; 491 | baseConfigurationReference = A984A2621450B32813D30803 /* Pods-WebViewBridgeDemo.release.xcconfig */; 492 | buildSettings = { 493 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 494 | INFOPLIST_FILE = WebViewBridgeDemo/Info.plist; 495 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 496 | PRODUCT_BUNDLE_IDENTIFIER = com.huangyibiao.WebViewBridgeDemo; 497 | PRODUCT_NAME = "$(TARGET_NAME)"; 498 | }; 499 | name = Release; 500 | }; 501 | 692FC34C1C8F99ED00D2799D /* Debug */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | BUNDLE_LOADER = "$(TEST_HOST)"; 505 | INFOPLIST_FILE = WebViewBridgeDemoTests/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = com.huangyibiao.WebViewBridgeDemoTests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewBridgeDemo.app/WebViewBridgeDemo"; 510 | }; 511 | name = Debug; 512 | }; 513 | 692FC34D1C8F99ED00D2799D /* Release */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | BUNDLE_LOADER = "$(TEST_HOST)"; 517 | INFOPLIST_FILE = WebViewBridgeDemoTests/Info.plist; 518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 519 | PRODUCT_BUNDLE_IDENTIFIER = com.huangyibiao.WebViewBridgeDemoTests; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewBridgeDemo.app/WebViewBridgeDemo"; 522 | }; 523 | name = Release; 524 | }; 525 | 692FC34F1C8F99ED00D2799D /* Debug */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | INFOPLIST_FILE = WebViewBridgeDemoUITests/Info.plist; 529 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 530 | PRODUCT_BUNDLE_IDENTIFIER = com.huangyibiao.WebViewBridgeDemoUITests; 531 | PRODUCT_NAME = "$(TARGET_NAME)"; 532 | TEST_TARGET_NAME = WebViewBridgeDemo; 533 | USES_XCTRUNNER = YES; 534 | }; 535 | name = Debug; 536 | }; 537 | 692FC3501C8F99ED00D2799D /* Release */ = { 538 | isa = XCBuildConfiguration; 539 | buildSettings = { 540 | INFOPLIST_FILE = WebViewBridgeDemoUITests/Info.plist; 541 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 542 | PRODUCT_BUNDLE_IDENTIFIER = com.huangyibiao.WebViewBridgeDemoUITests; 543 | PRODUCT_NAME = "$(TARGET_NAME)"; 544 | TEST_TARGET_NAME = WebViewBridgeDemo; 545 | USES_XCTRUNNER = YES; 546 | }; 547 | name = Release; 548 | }; 549 | /* End XCBuildConfiguration section */ 550 | 551 | /* Begin XCConfigurationList section */ 552 | 692FC3161C8F99ED00D2799D /* Build configuration list for PBXProject "WebViewBridgeDemo" */ = { 553 | isa = XCConfigurationList; 554 | buildConfigurations = ( 555 | 692FC3461C8F99ED00D2799D /* Debug */, 556 | 692FC3471C8F99ED00D2799D /* Release */, 557 | ); 558 | defaultConfigurationIsVisible = 0; 559 | defaultConfigurationName = Release; 560 | }; 561 | 692FC3481C8F99ED00D2799D /* Build configuration list for PBXNativeTarget "WebViewBridgeDemo" */ = { 562 | isa = XCConfigurationList; 563 | buildConfigurations = ( 564 | 692FC3491C8F99ED00D2799D /* Debug */, 565 | 692FC34A1C8F99ED00D2799D /* Release */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | 692FC34B1C8F99ED00D2799D /* Build configuration list for PBXNativeTarget "WebViewBridgeDemoTests" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | 692FC34C1C8F99ED00D2799D /* Debug */, 574 | 692FC34D1C8F99ED00D2799D /* Release */, 575 | ); 576 | defaultConfigurationIsVisible = 0; 577 | defaultConfigurationName = Release; 578 | }; 579 | 692FC34E1C8F99ED00D2799D /* Build configuration list for PBXNativeTarget "WebViewBridgeDemoUITests" */ = { 580 | isa = XCConfigurationList; 581 | buildConfigurations = ( 582 | 692FC34F1C8F99ED00D2799D /* Debug */, 583 | 692FC3501C8F99ED00D2799D /* Release */, 584 | ); 585 | defaultConfigurationIsVisible = 0; 586 | defaultConfigurationName = Release; 587 | }; 588 | /* End XCConfigurationList section */ 589 | }; 590 | rootObject = 692FC3131C8F99ED00D2799D /* Project object */; 591 | } 592 | -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderJackyHuang/WebViewJavascriptBridgeDemo/8184b0cfffa80e07ca41933e83604d472fef662f/WebViewBridgeDemo.xcodeproj/project.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/WebViewBridgeDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcodeproj/xcuserdata/huangyibiao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | WebViewBridgeDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 692FC31A1C8F99ED00D2799D 16 | 17 | primary 18 | 19 | 20 | 692FC3331C8F99ED00D2799D 21 | 22 | primary 23 | 24 | 25 | 692FC33E1C8F99ED00D2799D 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderJackyHuang/WebViewJavascriptBridgeDemo/8184b0cfffa80e07ca41933e83604d472fef662f/WebViewBridgeDemo.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /WebViewBridgeDemo.xcworkspace/xcuserdata/huangyibiao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WebViewBridgeDemo 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. 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 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WebViewBridgeDemo 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. 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 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/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 | } -------------------------------------------------------------------------------- /WebViewBridgeDemo/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 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/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 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/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 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WebViewBridgeDemo 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WebViewBridgeDemo 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WebViewJavascriptBridge.h" 11 | 12 | 13 | @interface ViewController () 14 | 15 | @property WebViewJavascriptBridge *bridge; 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; 25 | [self.view addSubview:webView]; 26 | 27 | NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]; 28 | NSString *appHtml = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; 29 | NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; 30 | [webView loadHTMLString:appHtml baseURL:baseURL]; 31 | 32 | // 开启日志 33 | [WebViewJavascriptBridge enableLogging]; 34 | 35 | // 给哪个webview建立JS与OjbC的沟通桥梁 36 | self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; 37 | [self.bridge setWebViewDelegate:self]; 38 | [self renderButtons:webView]; 39 | 40 | // JS主动调用OjbC的方法 41 | // 这是JS会调用getUserIdFromObjC方法,这是OC注册给JS调用的 42 | // JS需要回调,当然JS也可以传参数过来。data就是JS所传的参数,不一定需要传 43 | // OC端通过responseCallback回调JS端,JS就可以得到所需要的数据 44 | [self.bridge registerHandler:@"getUserIdFromObjC" handler:^(id data, WVJBResponseCallback responseCallback) { 45 | NSLog(@"js call getUserIdFromObjC, data from js is %@", data); 46 | if (responseCallback) { 47 | // 反馈给JS 48 | responseCallback(@{@"userId": @"123456"}); 49 | } 50 | }]; 51 | 52 | [self.bridge registerHandler:@"getBlogNameFromObjC" handler:^(id data, WVJBResponseCallback responseCallback) { 53 | NSLog(@"js call getBlogNameFromObjC, data from js is %@", data); 54 | if (responseCallback) { 55 | // 反馈给JS 56 | responseCallback(@{@"blogName": @"标哥的技术博客"}); 57 | } 58 | }]; 59 | 60 | [self.bridge callHandler:@"getUserInfos" data:@{@"name": @"标哥"} responseCallback:^(id responseData) { 61 | NSLog(@"from js: %@", responseData); 62 | }]; 63 | } 64 | 65 | - (void)webViewDidStartLoad:(UIWebView *)webView { 66 | NSLog(@"webViewDidStartLoad"); 67 | } 68 | 69 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 70 | NSLog(@"webViewDidFinishLoad"); 71 | } 72 | 73 | - (void)renderButtons:(UIWebView*)webView { 74 | UIFont* font = [UIFont fontWithName:@"HelveticaNeue" size:12.0]; 75 | 76 | UIButton *callbackButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 77 | [callbackButton setTitle:@"打开博文" forState:UIControlStateNormal]; 78 | [callbackButton addTarget:self action:@selector(onOpenBlogArticle:) forControlEvents:UIControlEventTouchUpInside]; 79 | [self.view insertSubview:callbackButton aboveSubview:webView]; 80 | callbackButton.frame = CGRectMake(10, 400, 100, 35); 81 | callbackButton.titleLabel.font = font; 82 | 83 | UIButton* reloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 84 | [reloadButton setTitle:@"刷新webview" forState:UIControlStateNormal]; 85 | [reloadButton addTarget:webView action:@selector(reload) forControlEvents:UIControlEventTouchUpInside]; 86 | [self.view insertSubview:reloadButton aboveSubview:webView]; 87 | reloadButton.frame = CGRectMake(110, 400, 100, 35); 88 | reloadButton.titleLabel.font = font; 89 | } 90 | 91 | - (void)onOpenBlogArticle:(id)sender { 92 | // 调用打开本demo的博文 93 | [self.bridge callHandler:@"openWebviewBridgeArticle" data:nil]; 94 | } 95 | 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WebViewBridgeDemo 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. 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 | -------------------------------------------------------------------------------- /WebViewBridgeDemo/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 |

WebViewJavascriptBridge Demo

15 | 16 | 73 | 74 |
75 | 76 |
77 | 78 |
79 | 80 | 81 | -------------------------------------------------------------------------------- /WebViewBridgeDemoTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebViewBridgeDemoTests/WebViewBridgeDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewBridgeDemoTests.m 3 | // WebViewBridgeDemoTests 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WebViewBridgeDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WebViewBridgeDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /WebViewBridgeDemoUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebViewBridgeDemoUITests/WebViewBridgeDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewBridgeDemoUITests.m 3 | // WebViewBridgeDemoUITests 4 | // 5 | // Created by huangyibiao on 16/3/9. 6 | // Copyright © 2016年 huangyibiao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WebViewBridgeDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WebViewBridgeDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------