Skip to content

Commit ecbaf71

Browse files
authored
Merge pull request #8 from finogeeks/fix/sdk-init
chore: 更新项目 demo
2 parents f656401 + aac1763 commit ecbaf71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+21575
-1851
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Windows files
2+
[*.bat]
3+
end_of_line = crlf

.flowconfig

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
; Ignore polyfills
99
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; These should not be required directly
12-
; require from fbjs/lib instead: require('fbjs/lib/warning')
13-
node_modules/warning/.*
14-
1511
; Flow doesn't support platforms
1612
.*/Libraries/Utilities/LoadingView.js
1713

@@ -27,8 +23,7 @@ node_modules/react-native/flow/
2723
[options]
2824
emoji=true
2925

30-
esproposal.optional_chaining=enable
31-
esproposal.nullish_coalescing=enable
26+
exact_by_default=true
3227

3328
module.file_ext=.js
3429
module.file_ext=.json
@@ -44,10 +39,6 @@ suppress_type=$FlowFixMe
4439
suppress_type=$FlowFixMeProps
4540
suppress_type=$FlowFixMeState
4641

47-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50-
5142
[lints]
5243
sketchy-null-number=warn
5344
sketchy-null-mixed=warn
@@ -56,10 +47,8 @@ untyped-type-import=warn
5647
nonstrict-import=warn
5748
deprecated-type=warn
5849
unsafe-getters-setters=warn
59-
inexact-spread=warn
6050
unnecessary-invariant=warn
6151
signature-verification-failure=warn
62-
deprecated-utility=error
6352

6453
[strict]
6554
deprecated-type
@@ -71,4 +60,4 @@ untyped-import
7160
untyped-type-import
7261

7362
[version]
74-
^0.113.0
63+
^0.149.0

.gitattributes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
*.pbxproj -text
2-
*.* linguist-language=javascript
3-
1+
# Windows files should use crlf line endings
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
*.bat text eol=crlf

.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
jsxBracketSameLine: true,
44
singleQuote: true,
55
trailingComma: 'all',
6+
arrowParens: 'avoid',
67
};

App.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
* https://github.com/facebook/react-native
99
*/
1010

11-
import React, { Component } from 'react';
12-
import { Platform, StyleSheet, Text, View, Button } from 'react-native';
11+
import React, {Component} from 'react';
12+
import {Platform, StyleSheet, Text, View, Button} from 'react-native';
1313
import MopSDK from 'react-native-mopsdk';
1414
const onPressOpenCanvasApplet = () => {
15-
MopSDK.openApplet('5ea03fa563cb900001d73863', '', '', (data) => { });
15+
MopSDK.openApplet('5ea03fa563cb900001d73863', '', '', data => {});
1616
};
1717
const onPressOpenDemoApplet = () => {
18-
MopSDK.openApplet('5ea0401463cb900001d73865', '', '', (data) => { });
18+
MopSDK.openApplet('5ea0401463cb900001d73865', '', '', data => {});
1919
};
2020
const onPressOpenProfileApplet = () => {
21-
MopSDK.openApplet('5ea0412663cb900001d73867', '', '', (data) => { });
21+
MopSDK.openApplet('5ea0412663cb900001d73867', '', '', data => {});
2222
};
2323
export default class App extends Component<{}> {
2424
state = {
@@ -30,10 +30,10 @@ export default class App extends Component<{}> {
3030
{
3131
appkey: '22LyZEib0gLTQdU3MUauASlb4KFRNRajt4RmY6UDSucA',
3232
secret: 'c5cc7a8c14a2b04a',
33-
apiServer: 'https://mp.finogeeks.com',
33+
apiServer: 'https://api.finclip.com',
3434
apiPrefix: '/api/v1/mop',
3535
},
36-
(data) => {
36+
data => {
3737
console.log('message;', data);
3838
const s = JSON.stringify(data);
3939
this.setState({

Readme.md

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@ System:
2424
Memory: 93.87 MB / 16.00 GB
2525
Shell: 3.2.57 - /bin/bash
2626
Binaries:
27-
Node: 10.20.1 - ~/.nvm/versions/node/v10.20.1/bin/node
27+
Node: 16.4.0 - ~/.nvm/versions/node/v10.20.1/bin/node
2828
Yarn: 1.22.4 - ~/.nvm/versions/node/v10.20.1/bin/yarn
29-
npm: 6.14.4 - ~/.nvm/versions/node/v10.20.1/bin/npm
29+
npm: 7.18.1 - ~/.nvm/versions/node/v10.20.1/bin/npm
3030
Watchman: Not Found
3131
Managers:
32-
CocoaPods: 1.9.1 - /usr/local/bin/pod
32+
CocoaPods: 1.10.1 - /usr/local/bin/pod
3333
SDKs:
3434
iOS SDK:
35-
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
35+
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
3636
Android SDK:
37-
API Levels: 26, 28, 29
38-
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0
39-
System Images: android-26 | Google Play Intel x86 Atom
40-
Android NDK: Not Found
37+
API Levels: 22, 23, 24, 25, 26, 27, 28, 29, 30
38+
Build Tools: 23.0.2, 23.0.3, 25.0.0, 26.0.2, 27.0.0, 27.0.3, 28.0.3, 29.0.2, 30.0.2
39+
System Images: android-28 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
40+
Android NDK: 21.3.6528147
4141
IDEs:
42-
Android Studio: 3.6 AI-192.7142.36.36.6241897
43-
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
42+
Android Studio: 4.0 AI-193.6911.18.40.6626763
43+
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
4444
Languages:
4545
Java: 10.0.1 - /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin/javac
4646
Python: 2.7.16 - /usr/bin/python
4747
npmPackages:
4848
@react-native-community/cli: Not Found
49-
react: 16.11.0 => 16.11.0
50-
react-native: 0.62.2 => 0.62.2
49+
react: 17.0.2 => 17.0.2
50+
react-native: 0.65.1 => 0.65.1
5151
npmGlobalPackages:
5252
*react-native*: Not Found
5353

@@ -79,22 +79,44 @@ react-native init mopdemo
7979
1. 引入小程序引擎插件。在 package.json 文件中引入小程序 ReactNative 插件
8080

8181
```javascript
82-
"react-native-mopsdk": "^1.0.1"
82+
"react-native-mopsdk": "^1.0.2"
8383
```
8484

85-
2. 在 main.dart 文件中增加以下小程序引擎初始化方法。 Mop.instance.initialize 这里需要用到 sdkkey 和 secret。可以直接在[https://mp.finogeeks.com](https://mp.finogeeks.com) 免费注册获取。注册使用方法可以参考 [接入指引](https://mp.finogeeks.com/mop/document/introduce/access/mechanism.html)
85+
android 在 build.gradle 添加 maven 配置
86+
87+
```bash
88+
maven {
89+
url "https://gradle.finogeeks.club/repository/applet/"
90+
credentials {
91+
username "applet"
92+
password "123321"
93+
}
94+
}
95+
```
96+
97+
iOS 需要重新 pod install
98+
99+
2. 在 App.js 文件中增加以下小程序引擎初始化方法。 Mop.instance.initialize 这里需要用到 sdkkey 和 secret。可以直接在[https://mp.finogeeks.com](https://mp.finogeeks.com) 免费注册获取。注册使用方法可以参考 [接入指引](https://mp.finogeeks.com/mop/document/introduce/access/mechanism.html)
86100

87101
```javascript
88102
import MopSDK from 'react-native-mopsdk';
89103
// 1. mop初始化
90-
MopSDK.initialize({
91-
appkey: '22LyZEib0gLTQdU3MUauASlb4KFRNRajt4RmY6UDSucA',
92-
secret: '4a915e447bcbd439',
93-
apiServer: 'https://mp.finogeeks.com',
94-
apiPrefix: '/api/v1/mop'
95-
}, (data) => {
96-
console.log('message;', data);
97-
});
104+
MopSDK.initialize(
105+
{
106+
appkey: '22LyZEib0gLTQdU3MUauASlb4KFRNRajt4RmY6UDSucA',
107+
secret: 'c5cc7a8c14a2b04a',
108+
apiServer: 'https://api.finclip.com',
109+
apiPrefix: '/api/v1/mop',
110+
},
111+
data => {
112+
console.log('message;', data);
113+
const s = JSON.stringify(data);
114+
this.setState({
115+
status: 'native callback received',
116+
message: s,
117+
});
118+
},
119+
);
98120
```
99121

100122
3. 打开小程序

android/app/BUCK

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ android_library(
3535

3636
android_build_config(
3737
name = "build_config",
38-
package = "com.example",
38+
package = "com.finogeeks.mop.rnexample",
3939
)
4040

4141
android_resource(
4242
name = "res",
43-
package = "com.example",
43+
package = "com.finogeeks.mop.rnexample",
4444
res = "src/main/res",
4545
)
4646

android/app/build.gradle

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.android.build.OutputFile
2020
* // default. Can be overridden with ENTRY_FILE environment variable.
2121
* entryFile: "index.android.js",
2222
*
23-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
2424
* bundleCommand: "ram-bundle",
2525
*
2626
* // whether to bundle JS and assets in debug mode
@@ -121,12 +121,9 @@ def jscFlavor = 'org.webkit:android-jsc:+'
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123123
android {
124-
compileSdkVersion rootProject.ext.compileSdkVersion
124+
ndkVersion rootProject.ext.ndkVersion
125125

126-
compileOptions {
127-
sourceCompatibility JavaVersion.VERSION_1_8
128-
targetCompatibility JavaVersion.VERSION_1_8
129-
}
126+
compileSdkVersion rootProject.ext.compileSdkVersion
130127

131128
defaultConfig {
132129
applicationId "com.finogeeks.mop.rnexample"
@@ -157,35 +154,24 @@ android {
157154
}
158155
release {
159156
// Caution! In production, you need to generate your own keystore file.
160-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
157+
// see https://reactnative.dev/docs/signed-apk-android.
161158
signingConfig signingConfigs.debug
162159
minifyEnabled enableProguardInReleaseBuilds
163160
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
164161
}
165162
}
166163

167-
packagingOptions {
168-
pickFirst "lib/armeabi-v7a/libc++_shared.so"
169-
pickFirst "lib/arm64-v8a/libc++_shared.so"
170-
pickFirst "lib/x86/libc++_shared.so"
171-
pickFirst "lib/x86_64/libc++_shared.so"
172-
// libsdkcore.so是被加固过的,不能被压缩,否则加载动态库时会报错
173-
doNotStrip "*/x86/libsdkcore.so"
174-
doNotStrip "*/x86_64/libsdkcore.so"
175-
doNotStrip "*/armeabi-v7a/libsdkcore.so"
176-
doNotStrip "*/arm64-v8a/libsdkcore.so"
177-
}
178-
179164
// applicationVariants are e.g. debug, release
180165
applicationVariants.all { variant ->
181166
variant.outputs.each { output ->
182167
// For each separate APK per architecture, set a unique version code as described here:
183168
// https://developer.android.com/studio/build/configure-apk-splits.html
169+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
184170
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
185171
def abi = output.getFilter(OutputFile.ABI)
186172
if (abi != null) { // null for the universal-debug, universal-release variants
187173
output.versionCodeOverride =
188-
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
174+
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
189175
}
190176

191177
}
@@ -205,6 +191,7 @@ dependencies {
205191

206192
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
207193
exclude group:'com.facebook.flipper'
194+
exclude group:'com.squareup.okhttp3', module:'okhttp'
208195
}
209196

210197
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
@@ -223,7 +210,7 @@ dependencies {
223210
// Run this once to be able to run the application with BUCK
224211
// puts all compile dependencies into folder libs for BUCK to use
225212
task copyDownloadableDepsToLibs(type: Copy) {
226-
from configurations.compile
213+
from configurations.implementation
227214
into 'libs'
228215
}
229216

android/app/src/debug/AndroidManifest.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44

55
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
66

7-
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
7+
<application
8+
android:usesCleartextTraffic="true"
9+
tools:targetApi="28"
10+
tools:ignore="GoogleAppIndexingWarning">
11+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
12+
</application>
813
</manifest>

android/app/src/debug/java/com/example/ReactNativeFlipper.java renamed to android/app/src/debug/java/com/mopdemo/ReactNativeFlipper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
55
* directory of this source tree.
66
*/
7-
package com.example;
7+
package com.finogeeks.mop.rnexample;
88

99
import android.content.Context;
1010
import com.facebook.flipper.android.AndroidFlipperClient;

0 commit comments

Comments
 (0)