nMobile Develop SetUp
1. Prepare for development
-
1.1 Download Android Studio(https://developer.android.google.cn/studio/).
-
1.2 Setup Android Studio environment.
-
1.3 Download Xcode to run on iOS Devices.
-
1.4 Download flutter (https://github.com/flutter/flutter),nMobile currently use 1.22.6.
-
1.5 Setup flutter environment,eg:
-
- export PUB_HOSTED_URL=https://pub.flutter-io.cn
-
- export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
-
- export PATH=/Users/UserName/Documents/flutter/bin:$PATH
-
- export DART_HOME=/Users/UserName/Documents/flutter/bin/cache/dart-sdk/bin
-
1.6 If you have setup gomobile develop environment,and want to modify SDK of NKN, fork https://github.com/nknorg/nkn-sdk-go. And you can make your own modification.
-
1.7 Checkout nMobile from github(https://github.com/nknorg/nMobile),Currently checkout dev of Tag Build220.
2. Replacement of nMobile App Setting
-
2.1 If you want notification function,open nMobile code with Android category.Find file “GooglePushService.java”(app/src/main/service/GooglePushService.java),change var “v0TokenString” to your own FirebaseCloudMessage setting.
-
2.2 Replace of “google-services.json”(app/google-services.json) with your own FCM setting.
-
2.3 Replace of “nkn.keystore”(app/key/nkn.keystore) with your own Android Sign key,modify the sign key locate in gradle.properties also.
-
2.4 Open iOS category with Xcode,find “NKNPushService.m”(Classes/NKNPush/NKNPushService.m),replace var “APNSPushFileName” with your own APNS .p12 or .cer file location,replace var “APNSPushPassword” with your own password of p12 file.
-
2.5 Click Xcode Build Settings, find “User-Defined”,replace “FLUTTER_APPLICATION_PATH”/“FLUTTER_FRAMEWORK_DIR”/“FLUTTER_ROOT” with your own flutter path.
3. MessageType
3.1 text
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | text | string | |
topic | string | Topic name,the 1-1 chat is null | |
content | object | JSON format | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. | |
options | json string |
3.2 textExtension
-
Burn after reading
-
Theme color (not implemented yet)
This is separated from text content type so web d-chat can simply ignore this content type if not implemented.
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | textExtension | string | |
topic | string | Topic name,the 1-1 chat is null | |
content | object | JSON format | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. | |
options | object |
3.3 Contact Protocol
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | contact | string | |
requestType | header/full | string | response should not contain this field |
content | {name: “”, avatar: { type: “base64”, data: “”}} | object | should not contain this field if request type is header |
version | string | random uuid | |
expiresAt | long | ||
onePieceReady | “1” | string | when sync this field,use 3.12 ContentType |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. |
If requestType is header, other side should respond with only version and expiresAt to indicate meta data.
If requestType is full, other side should include content as well.
3.4.1 Contact Options Protocol(for burnAfterReading function)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | event:contactOptions | string | |
content | {“deleteAfterSeconds”:10} | object | |
optionType | “0” | string | burn after reading function |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. |
3.4.2 Contact Options Protocol(for open notification bell function)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | event:contactOptions | string | |
content | {‘deviceToken’: “deviceToken value or empty string”} | object | enable or disable notification funtion |
optionType | “1” | string | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. |
3.5 receipt
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | receipt | string | |
targetID | string | target msg id | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. |
3.6 media (Suitable for D-Chat PC)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | media | string | |
topic | string | Topic name,the 1-1 chat is null | |
content | object | JSON format(check method “toSuitVersionImageData”) | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. | |
options | json string |
3.7 nknImage or image (Deprecated)/(Suitable for nMobile before 1.1.1)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | nknImage/image | string | |
topic | string | Topic name,the 1-1 chat is null | |
content | object | JSON format(check method “toImageData”) | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. | |
options | json string |
3.8 audio (Availble for current Audio Chat function)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | audio | string | |
topic | string | Topic name,the 1-1 chat is null | |
content | object | JSON format(check method “toAudioData”) | |
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. | |
options | {audioDuration:“7.56”} | json string | mark record audio time length |
3.9 event:subscribe (When subscribed group,broadcast this Type of message)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | event:subscribe | string | |
topic | string |
3.10 event:unsubscribe (When unsubscribed group,broadcast this Type of Message)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | event:unsubscribe | string | |
topic | string |
3.11 event:channelInvitation (When invite people join Group,send this Type of Message)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | event:channelInvitation | ||
content | object | JSON format |
3.12 nknOnePiece (In order to solve node delay)
field | value | type | description |
---|---|---|---|
id | string | random uuid | |
contentType | nknOnePiece | string | |
parentType | media or audio | string | currently support media/audio/3.7 ContentType |
content | object | JSON format | |
topic | string | Topic name,the 1-1 chat is null | |
options | json string | ||
timestamp | long | digital representation of time in milliseconds. for conversion to specific time in time zones around the world. | |
parity | 10 | int | Reed-solomon set,when received count==parity,see method “_combineOnePieceMessage” |
total | 13 | int | Reed-solomon total send count of messages |
index | 1 | int | current index of total messages |
bytesLength | 37620 | int | datasize length of origin message |
3.12.addtional
-
3.12.1 NKN nodes test pressure when sending one Message content above 60K(Sometime for more than 8hours of delay).
-
3.12.2 NKN group send test pressure when 80K over 300 members.
-
3.12.3 When send “image”/“audio” ContentType of Message,use reed-solomon to split the message into total pieces count with certain 1k/2k/4k/8k/16k,currently use 8k.
-
3.12.4 When receive “nknOnePiece” ContentType,wait for count reaches “parity” length of messages,then we can use reed-solomon to combine the split messages into the origin message.
-
3.12.5 See what is reed-solomon(https://github.com/klauspost/reedsolomon).
-
3.12.6 Why we use reed-solomon,in case of loss of messages due to bad network or through bad situation connection of nodes.