diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..680109b331c688f1849a6e33e393413c789000bd --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.* linguist-language=objective-c diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a4587ed8929da1c0a4be72b4380d2f8dbf35b3f --- /dev/null +++ b/.github/workflows/issue.yml @@ -0,0 +1,13 @@ +name: Notify +on: + issues: + types: [opened] + issue_comment: + types: [created] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Notify + run: curl --location --request POST 'https://api.finogeeks.club/api/v1/finstore/webhooks/61b331d79b3dad0001f72fa2/postreceive?nonce=jhd2QyrArsc' --header "Content-Type:application/json" --data-raw '{"msg":"仓库 ${{github.repository}} 有新的 issue"}' diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000000000000000000000000000000000000..b5872ff5746296c11ea24e8345da2b78e90de5f7 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,11 @@ +name: Notify +on: + pull_request: + branches: [ master ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Notify + run: curl --location --request POST 'https://api.finogeeks.club/api/v1/finstore/webhooks/61b331d79b3dad0001f72fa2/postreceive?nonce=jhd2QyrArsc' --header "Content-Type:application/json" --data-raw '{"msg":"仓库 ${{github.repository}} 有新的 PR ${{ github.event.pull_request._links.html.href }}"}' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..cf9c6f29f078ac0ae5e63852e63404487974a3c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Xcode +# +package-lock.json +Gemfile.lock +dist +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +out/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +Pods/ + +# Do not track our workspace since it is created by CocoaPods +*.xcworkspace +.DS_Store +build +build-* +out +out-* +Podfile.lock +data.json* +data1.json* +Riot/QSFramworks +stat.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6c0077e375c3d93a7efc9e625ef0eaa86983a970 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 finogeeks + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Podfile b/Podfile new file mode 100644 index 0000000000000000000000000000000000000000..ae305c54342a045286e51012f9f434bb7dcc9640 --- /dev/null +++ b/Podfile @@ -0,0 +1,12 @@ +platform :ios, "9.0" + + +inhibit_all_warnings! + +target "demo" do + pod 'FinApplet' + pod 'FinAppletExt' + pod 'WechatOpenSDK' +end + + diff --git a/demo.xcodeproj/project.pbxproj b/demo.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..8cb32cf3d1d30a4f84cfd891700a65001e7af002 --- /dev/null +++ b/demo.xcodeproj/project.pbxproj @@ -0,0 +1,436 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 9DD565BE23EC45080011FC4A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565BD23EC45080011FC4A /* AppDelegate.m */; }; + 9DD565C423EC45080011FC4A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565C323EC45080011FC4A /* ViewController.m */; }; + 9DD565C923EC450A0011FC4A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9DD565C823EC450A0011FC4A /* Assets.xcassets */; }; + 9DD565CC23EC450A0011FC4A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DD565CA23EC450A0011FC4A /* LaunchScreen.storyboard */; }; + 9DD565CF23EC450A0011FC4A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565CE23EC450A0011FC4A /* main.m */; }; + A0E041B926CE6DAD00D58D47 /* demo.plist in Resources */ = {isa = PBXBuildFile; fileRef = A0E041B826CE6DAD00D58D47 /* demo.plist */; }; + A0E041BB26CE6E1F00D58D47 /* finosprite.plist in Resources */ = {isa = PBXBuildFile; fileRef = A0E041BA26CE6E1F00D58D47 /* finosprite.plist */; }; + A0E041BD26CE720900D58D47 /* servers.plist in Resources */ = {isa = PBXBuildFile; fileRef = A0E041BC26CE720900D58D47 /* servers.plist */; }; + A823321F258C3B7000C1B2D5 /* FINDemoClientHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */; }; + A863B745257A09A300959AA1 /* FINExtensionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A863B744257A09A300959AA1 /* FINExtensionHelper.m */; }; + A8BC097A258BA095001289A3 /* FINCustomMenuModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */; }; + FBF7F422A6EA50C856DB84F7 /* libPods-demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28A582EE796CD12C1FF4F5DB /* libPods-demo.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 28A582EE796CD12C1FF4F5DB /* libPods-demo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-demo.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 3F2BFD149B6F799A303A07B3 /* Pods-demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo.release.xcconfig"; path = "Target Support Files/Pods-demo/Pods-demo.release.xcconfig"; sourceTree = ""; }; + 9DD565B923EC45080011FC4A /* demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9DD565BC23EC45080011FC4A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 9DD565BD23EC45080011FC4A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9DD565C223EC45080011FC4A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 9DD565C323EC45080011FC4A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 9DD565C823EC450A0011FC4A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9DD565CB23EC450A0011FC4A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9DD565CD23EC450A0011FC4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9DD565CE23EC450A0011FC4A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + A0E041B826CE6DAD00D58D47 /* demo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = demo.plist; sourceTree = ""; }; + A0E041BA26CE6E1F00D58D47 /* finosprite.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = finosprite.plist; sourceTree = ""; }; + A0E041BC26CE720900D58D47 /* servers.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = servers.plist; sourceTree = ""; }; + A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FINDemoClientHelper.m; sourceTree = ""; }; + A823321E258C3B7000C1B2D5 /* FINDemoClientHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FINDemoClientHelper.h; sourceTree = ""; }; + A863B743257A09A200959AA1 /* FINExtensionHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FINExtensionHelper.h; sourceTree = ""; }; + A863B744257A09A300959AA1 /* FINExtensionHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FINExtensionHelper.m; sourceTree = ""; }; + A8BC0978258BA095001289A3 /* FINCustomMenuModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FINCustomMenuModel.h; sourceTree = ""; }; + A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FINCustomMenuModel.m; sourceTree = ""; }; + FBEBA7E73B95B66C846E76FF /* Pods-demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo.debug.xcconfig"; path = "Target Support Files/Pods-demo/Pods-demo.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9DD565B623EC45080011FC4A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + FBF7F422A6EA50C856DB84F7 /* libPods-demo.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9DD565B023EC45080011FC4A = { + isa = PBXGroup; + children = ( + 9DD565BB23EC45080011FC4A /* demo */, + 9DD565BA23EC45080011FC4A /* Products */, + F230DA512C0C77A07ACE5BB1 /* Pods */, + ACE3AE3120D1733A6BB38C8A /* Frameworks */, + ); + sourceTree = ""; + }; + 9DD565BA23EC45080011FC4A /* Products */ = { + isa = PBXGroup; + children = ( + 9DD565B923EC45080011FC4A /* demo.app */, + ); + name = Products; + sourceTree = ""; + }; + 9DD565BB23EC45080011FC4A /* demo */ = { + isa = PBXGroup; + children = ( + 9DD565BC23EC45080011FC4A /* AppDelegate.h */, + 9DD565BD23EC45080011FC4A /* AppDelegate.m */, + A823321E258C3B7000C1B2D5 /* FINDemoClientHelper.h */, + A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */, + A863B743257A09A200959AA1 /* FINExtensionHelper.h */, + A863B744257A09A300959AA1 /* FINExtensionHelper.m */, + A8BC0978258BA095001289A3 /* FINCustomMenuModel.h */, + A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */, + 9DD565C223EC45080011FC4A /* ViewController.h */, + 9DD565C323EC45080011FC4A /* ViewController.m */, + 9DD565C823EC450A0011FC4A /* Assets.xcassets */, + 9DD565CA23EC450A0011FC4A /* LaunchScreen.storyboard */, + 9DD565CD23EC450A0011FC4A /* Info.plist */, + 9DD565CE23EC450A0011FC4A /* main.m */, + A0E041B826CE6DAD00D58D47 /* demo.plist */, + A0E041BA26CE6E1F00D58D47 /* finosprite.plist */, + A0E041BC26CE720900D58D47 /* servers.plist */, + ); + path = demo; + sourceTree = ""; + }; + ACE3AE3120D1733A6BB38C8A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 28A582EE796CD12C1FF4F5DB /* libPods-demo.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + F230DA512C0C77A07ACE5BB1 /* Pods */ = { + isa = PBXGroup; + children = ( + FBEBA7E73B95B66C846E76FF /* Pods-demo.debug.xcconfig */, + 3F2BFD149B6F799A303A07B3 /* Pods-demo.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9DD565B823EC45080011FC4A /* demo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9DD565D223EC450A0011FC4A /* Build configuration list for PBXNativeTarget "demo" */; + buildPhases = ( + E71B82096235B4713AA534F8 /* [CP] Check Pods Manifest.lock */, + 9DD565B523EC45080011FC4A /* Sources */, + 9DD565B623EC45080011FC4A /* Frameworks */, + 9DD565B723EC45080011FC4A /* Resources */, + D5CFBA4174EF15FFF4AA041A /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = demo; + productName = demo; + productReference = 9DD565B923EC45080011FC4A /* demo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9DD565B123EC45080011FC4A /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = finogeeks; + TargetAttributes = { + 9DD565B823EC45080011FC4A = { + CreatedOnToolsVersion = 11.3.1; + }; + }; + }; + buildConfigurationList = 9DD565B423EC45080011FC4A /* Build configuration list for PBXProject "demo" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9DD565B023EC45080011FC4A; + productRefGroup = 9DD565BA23EC45080011FC4A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9DD565B823EC45080011FC4A /* demo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9DD565B723EC45080011FC4A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9DD565CC23EC450A0011FC4A /* LaunchScreen.storyboard in Resources */, + A0E041BB26CE6E1F00D58D47 /* finosprite.plist in Resources */, + A0E041B926CE6DAD00D58D47 /* demo.plist in Resources */, + 9DD565C923EC450A0011FC4A /* Assets.xcassets in Resources */, + A0E041BD26CE720900D58D47 /* servers.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + D5CFBA4174EF15FFF4AA041A /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + E71B82096235B4713AA534F8 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-demo-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9DD565B523EC45080011FC4A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9DD565C423EC45080011FC4A /* ViewController.m in Sources */, + A823321F258C3B7000C1B2D5 /* FINDemoClientHelper.m in Sources */, + A8BC097A258BA095001289A3 /* FINCustomMenuModel.m in Sources */, + A863B745257A09A300959AA1 /* FINExtensionHelper.m in Sources */, + 9DD565BE23EC45080011FC4A /* AppDelegate.m in Sources */, + 9DD565CF23EC450A0011FC4A /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9DD565CA23EC450A0011FC4A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9DD565CB23EC450A0011FC4A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 9DD565D023EC450A0011FC4A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 9DD565D123EC450A0011FC4A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9DD565D323EC450A0011FC4A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FBEBA7E73B95B66C846E76FF /* Pods-demo.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9QCKYFU5M4; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = demo/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.finogeeks.finclip.demo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9DD565D423EC450A0011FC4A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3F2BFD149B6F799A303A07B3 /* Pods-demo.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = 9QCKYFU5M4; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = demo/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.finogeeks.finclip.demo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = github_demo_adhoc; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9DD565B423EC45080011FC4A /* Build configuration list for PBXProject "demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9DD565D023EC450A0011FC4A /* Debug */, + 9DD565D123EC450A0011FC4A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9DD565D223EC450A0011FC4A /* Build configuration list for PBXNativeTarget "demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9DD565D323EC450A0011FC4A /* Debug */, + 9DD565D423EC450A0011FC4A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9DD565B123EC45080011FC4A /* Project object */; +} diff --git a/demo/AppDelegate.h b/demo/AppDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..0c81cac27576c7852922713355f644e1559e9ecf --- /dev/null +++ b/demo/AppDelegate.h @@ -0,0 +1,16 @@ +// +// AppDelegate.h +// demo +// +// Created by 杨涛 on 2020/2/6. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end + diff --git a/demo/AppDelegate.m b/demo/AppDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..41a0dfc4dd4525cc0c9435aebb04a543507c4d9f --- /dev/null +++ b/demo/AppDelegate.m @@ -0,0 +1,67 @@ +// +// AppDelegate.m +// demo +// +// Created by 杨涛 on 2020/2/6. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import "AppDelegate.h" +#import "ViewController.h" +#import "FINExtensionHelper.h" +#import "FINDemoClientHelper.h" + +#import +#import + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + + // servers.plist维护了不同应用,初始化finclip的参数(因为微信支付需要绑定一个可用的账号) + NSString *bundleId = [NSBundle mainBundle].bundleIdentifier; + NSString *path = [[NSBundle mainBundle] pathForResource:@"servers" ofType:@"plist"]; + NSDictionary *servers = [NSDictionary dictionaryWithContentsOfFile:path]; + NSDictionary *data = servers[bundleId]; + NSString *appKey = data[@"appKey"]; + NSString *appSecret = data[@"appSecret"]; + NSString *apiServer = data[@"apiServer"]; + NSString *apiPrefix = data[@"apiPrefix"]; + FATApiCryptType cryptType = [data[@"cryptType"] isEqualToString:@"MD5"] ? FATApiCryptTypeMD5 : FATApiCryptTypeSM; + + FATConfig *config = [FATConfig configWithAppSecret:appSecret appKey:appKey]; + config.apiServer = apiServer; + config.apiPrefix = apiPrefix; + config.cryptType = cryptType; + [[FATClient sharedClient] initWithConfig:config error:nil]; + [[FATClient sharedClient] setEnableLog:YES]; + + [FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper]; + // 注入自定义api + [[FINExtensionHelper sharedHelper] registerCustomApis]; + + // 该appID【wx85663af68a0cbbc8】绑定的应用为凡泰助手,若要生效,请修改BundleID为com.finogeeks.mop.finosprite + [WXApi registerApp:@"wx85663af68a0cbbc8" universalLink:apiServer]; + + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + self.window.backgroundColor = [UIColor whiteColor]; + self.window.rootViewController = [[ViewController alloc] init]; + [self.window makeKeyAndVisible]; + + return YES; +} + +- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { + if ([url.scheme isEqualToString:@"wx85663af68a0cbbc8"]) { + return [WXApi handleOpenURL:url delegate:(id _Nullable)[FINExtensionHelper sharedHelper]]; + } + return YES; +} + +@end diff --git a/demo/Assets.xcassets/AppIcon.appiconset/Contents.json b/demo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..d8db8d65fd79fd541b2b7eba75c7378af3448f9c --- /dev/null +++ b/demo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demo/Assets.xcassets/Contents.json b/demo/Assets.xcassets/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..73c00596a7fca3f3d4bdd64053b69d86745f9e10 --- /dev/null +++ b/demo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/demo/Assets.xcassets/minipro_list_collect.imageset/Contents.json b/demo/Assets.xcassets/minipro_list_collect.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..96dd9230ec36c8e48e6462949762a4adff0439dc --- /dev/null +++ b/demo/Assets.xcassets/minipro_list_collect.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "minipro_list_collect@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "minipro_list_collect@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@2x.png b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..1b517c17a676e62310515fd402841808c501f4d3 Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@2x.png differ diff --git a/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@3x.png b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..cf4dfb1fc1195e59439cd493ced049f38492528c Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@3x.png differ diff --git a/demo/Assets.xcassets/minipro_list_service.imageset/Contents.json b/demo/Assets.xcassets/minipro_list_service.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..4a2d688af804b94e0675fdafd59244f0a2b49365 --- /dev/null +++ b/demo/Assets.xcassets/minipro_list_service.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "minipro_list_service@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "minipro_list_service@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@2x.png b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..5b5e785eeea928ebcef79b771d14b9e2ee43a411 Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@2x.png differ diff --git a/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@3x.png b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..bc2db4052bb612ed1a120f6a04443fb1cb7fc82f Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@3x.png differ diff --git a/demo/Base.lproj/LaunchScreen.storyboard b/demo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..865e9329f3767a7c1dd66294b8025bf81dee7d2c --- /dev/null +++ b/demo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/FINCustomMenuModel.h b/demo/FINCustomMenuModel.h new file mode 100644 index 0000000000000000000000000000000000000000..194a608bde871e15a3419a0d7560a41285b2c51d --- /dev/null +++ b/demo/FINCustomMenuModel.h @@ -0,0 +1,18 @@ +// +// FINCustomMenuModel.h +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface FINCustomMenuModel : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/demo/FINCustomMenuModel.m b/demo/FINCustomMenuModel.m new file mode 100644 index 0000000000000000000000000000000000000000..d500264058cb23c2581554e698cb9f1ae42e1497 --- /dev/null +++ b/demo/FINCustomMenuModel.m @@ -0,0 +1,24 @@ +// +// FINCustomMenuModel.m +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import "FINCustomMenuModel.h" + +@implementation FINCustomMenuModel + +@synthesize menuId, menuIconImage, menuTitle, menuType; + +- (id)copyWithZone:(NSZone *)zone +{ + FINCustomMenuModel *model = [[FINCustomMenuModel allocWithZone:zone] init]; + model.menuId = self.menuId; + model.menuIconImage = self.menuIconImage; + model.menuTitle = self.menuTitle; + return model; +} + +@end diff --git a/demo/FINDemoClientHelper.h b/demo/FINDemoClientHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..9c77e587e4473098f766d7fa601900f63311d4ac --- /dev/null +++ b/demo/FINDemoClientHelper.h @@ -0,0 +1,17 @@ +// +// FINClientHelper.h +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import +#import + +@interface FINDemoClientHelper : NSObject + ++ (instancetype)sharedHelper; + +@end + diff --git a/demo/FINDemoClientHelper.m b/demo/FINDemoClientHelper.m new file mode 100644 index 0000000000000000000000000000000000000000..cd79cc850d63d439b4386c5bd6237ec6b955d009 --- /dev/null +++ b/demo/FINDemoClientHelper.m @@ -0,0 +1,127 @@ +// +// FINClientHelper.m +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import "FINDemoClientHelper.h" +#import "FINCustomMenuModel.h" + +static FINDemoClientHelper *instance = nil; + +@implementation FINDemoClientHelper + ++ (instancetype)sharedHelper { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [[[self class] alloc] init]; + }); + return instance; +} + ++ (instancetype)allocWithZone:(struct _NSZone *)zone { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [super allocWithZone:zone]; + }); + return instance; +} + +- (id)copy { + return instance; +} + +#pragma mark - FATAppletDelegate +- (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion +{ + NSLog(@"小程序信息:%@", contentInfo); + + // 1.如果你需要将小程序转发到自己app的聊天室,那么就根据contentInfo封装成自己IM消息,然后发送。 + + // 2.如果你需要将小程序转发到自己app的朋友圈,那么就根据contentInfo,组装信息发送给后台。 +} + +/// 小程序灰度扩展参数 +/// @param appletId 小程序id +- (NSDictionary *)grayExtensionWithAppletId:(NSString *)appletId +{ + if ([appletId isEqualToString:@"5facb3a52dcbff00017469bd"]) { + return @{@"phone":@(1234567890)}; + } + + if ([appletId isEqualToString:@"5fa214a29a6a7900019b5cc1"]) { + return @{@"token":@"xxxxxtoken"}; + } + + return @{@"key1":@"value1"}; +} + +#pragma mark - more menu +/// 更多按钮中自定义的菜单,会在页面弹出菜单时调用该api +/// @param appletInfo 小程序信息 +/// @param path 页面路径 +- (NSArray> *)customMenusInApplet:(FATAppletInfo *)appletInfo atPath:(NSString *)path +{ + NSString *appletId = appletInfo.appId; + if ([appletId isEqualToString:@"5facb3a52dcbff00017469bd"]) { + FINCustomMenuModel *favModel1 = [[FINCustomMenuModel alloc] init]; + favModel1.menuId = @"1001"; + favModel1.menuTitle = @"客服"; + favModel1.menuIconImage = [UIImage imageNamed:@"minipro_list_service"]; + + return @[favModel1]; + } + + if ([appletId isEqualToString:@"5fa214a29a6a7900019b5cc1"]) { + FINCustomMenuModel *favModel2 = [[FINCustomMenuModel alloc] init]; + favModel2.menuId = @"1002"; + favModel2.menuTitle = @"收藏"; + favModel2.menuIconImage = [UIImage imageNamed:@"minipro_list_collect"]; + + return @[favModel2]; + } + + FINCustomMenuModel *favModel1 = [[FINCustomMenuModel alloc] init]; + favModel1.menuId = @"1003"; + favModel1.menuTitle = @"客服"; + favModel1.menuIconImage = [UIImage imageNamed:@"minipro_list_service"]; + + FINCustomMenuModel *favModel2 = [[FINCustomMenuModel alloc] init]; + favModel2.menuId = @"1004"; + favModel2.menuTitle = @"收藏"; + favModel2.menuIconImage = [UIImage imageNamed:@"minipro_list_collect"]; + + return @[favModel1, favModel2]; +} + +/// 点击自定义菜单时,会触发的事件 +/// @param customMenu 自定义菜单对象 +/// @param appletInfo 小程序信息 +/// @param path 当前页面路径 +- (void)customMenu:(id)customMenu inApplet:(FATAppletInfo *)appletInfo didClickAtPath:(NSString *)path +{ + NSLog(@"自定义按钮被点击"); + if ([customMenu.menuId isEqual:@"1001"]) { + NSLog(@"客服按钮被点击"); + return; + } + + if ([customMenu.menuId isEqual:@"1002"]) { + NSLog(@"收藏按钮被点击"); + // 1.获取用户id +// NSString *userId = @""; +// +// // 2.获取小程序id +// NSString *appletId = appletInfo.appId; +// +// NSDictionary *param = @{@"userId":userId,@"appletId":appletId}; + // 3.调用网络接口 +// [FINNetworkClient postParam:param completion:]; + + return; + } +} + +@end diff --git a/demo/FINExtensionHelper.h b/demo/FINExtensionHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..378256964220da16b34582204149d12a3c8c4d47 --- /dev/null +++ b/demo/FINExtensionHelper.h @@ -0,0 +1,17 @@ +// +// FINExtensionHelper.h +// finclip_custom_demo +// +// Created by Haley on 2020/12/3. +// + +#import + +@interface FINExtensionHelper : NSObject + ++ (instancetype)sharedHelper; + +- (void)registerCustomApis; + +@end + diff --git a/demo/FINExtensionHelper.m b/demo/FINExtensionHelper.m new file mode 100644 index 0000000000000000000000000000000000000000..38d03e6f503bc7e9a44941f670f4bc2da73c3b5c --- /dev/null +++ b/demo/FINExtensionHelper.m @@ -0,0 +1,160 @@ +// +// FINExtensionHelper.m +// finclip_custom_demo +// +// Created by Haley on 2020/12/3. +// + +#import "FINExtensionHelper.h" +#import +#import +#import +#import + +@interface FINExtensionHelper () + +// 支付时,支付的回调是异步的,故这里将小程序的回调持有,在适当的时机调用(用户可根据自己的场景自行实现自己调用的逻辑) +@property (nonatomic, copy) FATExtensionApiCallback callback; + +@end + +static FINExtensionHelper *instance = nil; + +@implementation FINExtensionHelper + ++ (instancetype)sharedHelper { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [[FINExtensionHelper alloc] init]; + }); + return instance; +} + ++ (instancetype)allocWithZone:(struct _NSZone *)zone { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [super allocWithZone:zone]; + }); + return instance; +} + +- (id)copy { + return instance; +} + +// 注入自定义api +- (void)registerCustomApis { + [[FATClient sharedClient] registerExtensionApi:@"onNative" handle:^(id param, FATExtensionApiCallback callback) { + NSString *inputText = @"床前明月光,疑是地上霜。举头望明月,低头思故乡。"; + callback(FATExtensionCodeSuccess, @{@"text":inputText}); + }]; + + [[FATClient sharedClient] fat_registerWebApi:@"user_define_native" handle:^(id param, FATExtensionApiCallback callback) { + NSString *inputText = @"鹅鹅鹅,曲项向天歌,白毛浮绿水,红掌拨清波。"; + callback(FATExtensionCodeSuccess, @{@"text":inputText}); + }]; + + // 注入获取用户信息 + [[FATClient sharedClient] registerExtensionApi:@"getUserProfile" handle:^(id param, FATExtensionApiCallback callback) { + NSDictionary *userInfo = @{@"nickName":@"张三",@"avatarUrl":@"",@"gender":@1,@"country":@"中国",@"province":@"广东省",@"city":@"深圳",@"language":@"zh_CN"}; + NSDictionary *resDic = @{@"userInfo":userInfo}; + callback(FATExtensionCodeSuccess,resDic); + }]; + // 注入登录方法 + [[FATClient sharedClient] registerExtensionApi:@"login" handle:^(id param, FATExtensionApiCallback callback) { + // 处理小程序登录逻辑后,调用小程序回调 + // 登录成功回调示例 + callback(FATExtensionCodeSuccess,@{@"desc":@"登录成功"}); + }]; + // 注入微信支付方法 + __weak typeof(self) weakSelf = self; + [[FATClient sharedClient] registerExtensionApi:@"requestPayment" handle:^(id param, FATExtensionApiCallback callback) { + // 支付调用,调用结果通过回调通告小程序 + [weakSelf getTestPayment:callback]; + }]; +} + +#pragma mark - WXPay +// 模拟向服务请求支付订单 +- (void)getTestPayment:(FATExtensionApiCallback)callback { + NSString *urlString = @"https://finclip-testing.finogeeks.club/mop/wechat-auth/api/order"; + NSURL *url = [NSURL URLWithString:urlString]; + NSMutableURLRequest *requset = [NSMutableURLRequest requestWithURL:url]; + requset.HTTPMethod = @"POST"; + __weak typeof(self) weakSelf = self; + NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:requset completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + if (httpResponse.statusCode == 200) { + NSString *appId = @"wx85663af68a0cbbc8"; + NSString *partnerId = @"1600932850"; + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil]; + NSString *prepayId = dict[@"data"][@"prepay_id"]; + NSString *nonceStr = @"5K8264ILTKCH16CQ2502SI8ZNMTM67VS"; // 随机字符串,这里就不模拟了 + UInt32 timeStamp = [[NSDate date] timeIntervalSince1970]; + NSString *text = [NSString stringWithFormat:@"%@\n%ld\n%@\n%@\n", appId, (long)timeStamp, nonceStr, prepayId]; + NSString *sign = [weakSelf sha256:text]; + PayReq *request = [[PayReq alloc] init]; + request.partnerId = partnerId; + request.prepayId = prepayId; + request.package = @"Sign=WXPay"; + request.nonceStr = nonceStr; + request.timeStamp = timeStamp; + request.sign= sign; + dispatch_async(dispatch_get_main_queue(), ^{ + [WXApi sendReq:request completion:^(BOOL success) { + if (success) { + weakSelf.callback = callback; + } else { + callback(FATExtensionCodeFailure, nil); + } + }]; + }); + return; + } + callback(FATExtensionCodeFailure, nil); + }]; + [task resume]; +} + +// 签名加密(正常是放在后台处理,由上面的请求接口返回 +- (NSString *)sha256:(NSString *)shaStr { + NSData *data = [shaStr dataUsingEncoding:NSUTF8StringEncoding]; + uint8_t digest[CC_SHA256_DIGEST_LENGTH]; + CC_SHA256(data.bytes, (CC_LONG)data.length, digest); + NSData *adata = [[NSData alloc] initWithBytes:digest length:CC_SHA256_DIGEST_LENGTH]; + adata = [adata base64EncodedDataWithOptions:0]; + NSString *ret = [[NSString alloc] initWithData:adata encoding:NSUTF8StringEncoding]; + return ret; +} + +#pragma mark - WXApiDelegate +//发起支付请求回调 +- (void)onReq:(BaseReq *)req { + +} + +//支付结果回调 +- (void)onResp:(BaseResp *)resp { + if ([resp isKindOfClass:[PayResp class]]) { + PayResp *response = (PayResp*)resp; + //response.errCode +// WXSuccess = 0, /**< 成功 */ +// WXErrCodeCommon = -1, /**< 普通错误类型 */ +// WXErrCodeUserCancel = -2, /**< 用户点击取消并返回 */ +// WXErrCodeSentFail = -3, /**< 发送失败 */ +// WXErrCodeAuthDeny = -4, /**< 授权失败 */ +// WXErrCodeUnsupport = -5, /**< 微信不支持 */ + switch (response.errCode) { + case WXSuccess: + self.callback(FATExtensionCodeSuccess, nil); + break; + + default: + self.callback(FATExtensionCodeFailure, nil); + break; + } + } +} + + +@end diff --git a/demo/Info.plist b/demo/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..f14de6c0cd41486ce45d0f8bbe5f6b5526c9c448 --- /dev/null +++ b/demo/Info.plist @@ -0,0 +1,82 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + weixin + CFBundleURLSchemes + + wx85663af68a0cbbc8 + + + + CFBundleVersion + 1 + LSApplicationQueriesSchemes + + weixin + weixinULAPI + + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSBluetoothPeripheralUsageDescription + 是否允许【FinApplet】使用蓝牙? + NSCalendarsUsageDescription + 是否允许【FinApplet】使用日历? + NSCameraUsageDescription + 是否允许【FinApplet】使用你的相机? + NSContactsUsageDescription + 开启同步通讯录信息,可智能补全客户资料。如果系统提示确认权限,请点击“好”。 + NSLocationAlwaysUsageDescription + 我们需要通过您的地理位置信息获取您周边的相关数据 + NSLocationWhenInUseUsageDescription + 我们需要通过您的地理位置信息获取您周边的相关数据 + NSMicrophoneUsageDescription + 是否允许【FinApplet】使用你的麦克风? + NSPhotoLibraryUsageDescription + 是否允许【FinApplet】使用语相册? + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/demo/ViewController.h b/demo/ViewController.h new file mode 100644 index 0000000000000000000000000000000000000000..3d4ba293a23ec62780df6c46d8597c64a624be04 --- /dev/null +++ b/demo/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// demo +// +// Created by 杨涛 on 2020/2/6. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/demo/ViewController.m b/demo/ViewController.m new file mode 100644 index 0000000000000000000000000000000000000000..c7b97c707a3115fa560c61955906722ec3e655d2 --- /dev/null +++ b/demo/ViewController.m @@ -0,0 +1,105 @@ +// +// ViewController.m +// demo +// +// Created by 杨涛 on 2020/2/6. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import "ViewController.h" +#import +#import + +@interface ViewController () + +@property (nonatomic, strong) UITableView *tableView; + +@property (nonatomic, strong) NSMutableArray *appletList; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + + [self p_loadData]; + + [self p_initSubViews]; +} + +- (void)p_initSubViews { + CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; + CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; + + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 44)]; + headerView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1]; + + self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight) style:UITableViewStylePlain]; + self.tableView.tableHeaderView = headerView; + self.tableView.tableFooterView = [UIView new]; + self.tableView.delegate = self; + self.tableView.dataSource = self; + [self.view addSubview:self.tableView]; +} + +- (void)p_loadData { + // 配置小程序列表 + self.appletList = [[NSMutableArray alloc] init]; + NSString *bundleId = [NSBundle mainBundle].bundleIdentifier; + NSString *appName = [bundleId componentsSeparatedByString:@"."].lastObject; + if (![appName isEqualToString:@""]) { + NSString *path = [[NSBundle mainBundle] pathForResource:appName ofType:@"plist"]; + NSArray *array = [NSArray arrayWithContentsOfFile:path]; + for (NSDictionary *dict in array) { + [self.appletList addObject:dict]; + } + } + [self.tableView reloadData]; +} + +// 原生向小程序发送的事件 +- (void)sendCustomEvent { + if (@available(iOS 10.0, *)) { + [NSTimer scheduledTimerWithTimeInterval:3 repeats:YES block:^(NSTimer * _Nonnull timer) { + NSTimeInterval timestamp = [[NSDate date] timeIntervalSince1970]; + [[FATClient sharedClient].nativeViewManager sendCustomEventWithDetail:@{@"timestamp":@(timestamp)} completion:^(id result, NSError *error) { + NSLog(@"sendCustomEventW:%@", error); + }]; + }]; + } +} + +#pragma mark - UITableViewDataSource +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.appletList.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *identifer = @"identifer"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifer]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer]; + } + + NSDictionary *dict = self.appletList[indexPath.row]; + cell.textLabel.text = dict[@"title"]; + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + + NSDictionary *dict = self.appletList[indexPath.row]; + NSString *appId = dict[@"appId"]; + NSDictionary *startParams = dict[@"startParams"]; + + [[FATClient sharedClient] startRemoteApplet:appId startParams:startParams InParentViewController:self completion:^(BOOL result, NSError *error) { + if ([appId isEqualToString:@"60c5bbf99e094f00015079ee"]) { + [self sendCustomEvent]; + } + }]; +} + +@end diff --git a/demo/demo.plist b/demo/demo.plist new file mode 100644 index 0000000000000000000000000000000000000000..3981c808f2d377fde2dfe53a38d52a348eb34eda --- /dev/null +++ b/demo/demo.plist @@ -0,0 +1,65 @@ + + + + + + appId + 5facb3a52dcbff00017469bd + title + 绘图小程序 + startParams + + + + appId + 5fa214a29a6a7900019b5cc1 + title + 官方示例小程序 + startParams + + + + appId + 5fa215459a6a7900019b5cc3 + title + 对账单 + startParams + + + + appId + 5fc8934aefb8c600019e9747 + title + 自定义小程序API示例 + startParams + + + + appId + 5fc8934aefb8c600019e9747 + title + 自定义H5 API示例 + startParams + + path + /pages/webview/webview + + + + appId + 60c5bbf99e094f00015079ee + title + 原生向小程序发送事件 + startParams + + + + appId + 60f051ea525ea10001c0bd22 + title + 小程序登录授权示例 + startParams + + + + diff --git a/demo/finosprite.plist b/demo/finosprite.plist new file mode 100644 index 0000000000000000000000000000000000000000..1f9da87c19aab88b16787016bebe45b73c5234a0 --- /dev/null +++ b/demo/finosprite.plist @@ -0,0 +1,14 @@ + + + + + + appId + 611cf17739245f000182fa40 + title + 小程序微信登录&支付示例 + startParams + + + + diff --git a/demo/main.m b/demo/main.m new file mode 100644 index 0000000000000000000000000000000000000000..7514bf5c8eab9adfd72817235da5123e9baa43b3 --- /dev/null +++ b/demo/main.m @@ -0,0 +1,19 @@ +// +// main.m +// demo +// +// Created by 杨涛 on 2020/2/6. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +} diff --git a/demo/servers.plist b/demo/servers.plist new file mode 100644 index 0000000000000000000000000000000000000000..8dd6317fb5ab04283b1460a9ce96557f98f736ea --- /dev/null +++ b/demo/servers.plist @@ -0,0 +1,32 @@ + + + + + com.finogeeks.finclip.demo + + appKey + 22LyZEib0gLTQdU3MUauATBwgfnTCJjdr7FCnywmAEM= + appSecret + bdfd76cae24d4313 + apiServer + https://api.finclip.com + apiPrefix + /api/v1/mop/ + cryptType + MD5 + + com.finogeeks.mop.finosprite + + appKey + 22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk= + appSecret + ae55433be2f62915 + apiServer + https://finchat-mop-b.finogeeks.club + apiPrefix + /api/v1/mop/ + cryptType + SM + + + diff --git a/doc/mop_ios_demo.gif b/doc/mop_ios_demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..963134753bdcc6eb8cea23417e377d862d5b6a00 Binary files /dev/null and b/doc/mop_ios_demo.gif differ diff --git a/finclip-ios-demo.zip b/finclip-ios-demo.zip deleted file mode 100644 index 1765cceedc939d39c7a58399016ad651639a2325..0000000000000000000000000000000000000000 Binary files a/finclip-ios-demo.zip and /dev/null differ diff --git a/media/image/demo_readme2.png b/media/image/demo_readme2.png new file mode 100644 index 0000000000000000000000000000000000000000..9b5f0e6ef334869fd7eaa6a4f10800a48bcfff7b Binary files /dev/null and b/media/image/demo_readme2.png differ diff --git a/media/image/image-1612508915946.jpeg b/media/image/image-1612508915946.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..a05f77723bfaf4a031c8bca0836d1d57d2e12585 Binary files /dev/null and b/media/image/image-1612508915946.jpeg differ