Skip to content

Commit

Permalink
fix: fix packetsReceiptNotificationsValue for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonos committed Jan 14, 2024
1 parent fdf116d commit 2919c16
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
example/www
example/ios
example/android
example/.angular
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"files.eol": "\n",
"files.insertFinalNewline": true,
"terminal.integrated.scrollback": 10000,
"terminal.integrated.defaultProfile.osx": "zsh",

// Todo tree settings
"todo-tree.general.tags": ["BUG", "HACK", "FIXME", "TODO", "INFO"],
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This guide provides instructions for contributing to this Capacitor plugin.

#### Android studio

Download and install [Android studio](https://developer.android.com/studio). The code has been developed using `Android Studio Giraffe | 2022.3.1 Patch 3`
Download and install [Android studio](https://developer.android.com/studio). The code has been developed using `Android Studio Hedgehog | 2023.1.1 Patch 1`

#### Xcode

Expand Down
12 changes: 7 additions & 5 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.plugin.nordicdfu">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application>
<service
android:name=".DfuService"
android:foregroundServiceType="connectedDevice" />
<activity android:name=".NotificationActivity"/>
android:foregroundServiceType="connectedDevice" />
<activity android:name=".NotificationActivity" />
</application>

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.example.plugin.nordicdfu;

import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.getcapacitor.JSObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void startDFU(PluginCall call) {
}

if (dfuOptions.has("packetsReceiptNotificationsValue")) {
starter.setPacketsReceiptNotificationsValue(dfuOptions.optInt("packetReceiptNotificationsEnabled"));
starter.setPacketsReceiptNotificationsValue(dfuOptions.optInt("packetsReceiptNotificationsValue"));
}

if (dfuOptions.has("forceDfu")) {
Expand Down
11 changes: 5 additions & 6 deletions ios/Plugin/NordicDfuPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
var notification: JSObject = [
"id": Int(request.identifier) ?? -1,
"title": request.content.title,
"body": request.content.body,
"body": request.content.body
]

if let userInfo = JSTypes.coerceDictionaryToJSObject(request.content.userInfo) {
Expand Down Expand Up @@ -73,7 +73,7 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
return [
.badge,
.sound,
.alert,
.alert
]
}

Expand Down Expand Up @@ -157,15 +157,15 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
"currentPart": part,
"partsTotal": totalParts,
"duration": duration,
"remainingTime": remainingTime,
"remainingTime": remainingTime
]
sendStateUpdate("DFU_PROGRESS", data)
}

private func sendStateUpdate(_ state: String, _ data: JSObject = [:]) {
let ret: JSObject = [
"state": state,
"data": data,
"data": data
]
notifyListeners(dfuChangeEvent, data: ret)
}
Expand Down Expand Up @@ -258,8 +258,7 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
// }

if let packetsReceiptNotificationsValueStr = dfuOption["packetsReceiptNotificationsValue"] as? String,
let packetsReceiptNotificationsValue = UInt16(packetsReceiptNotificationsValueStr)
{
let packetsReceiptNotificationsValue = UInt16(packetsReceiptNotificationsValueStr) {
starter.packetReceiptNotificationParameter = packetsReceiptNotificationsValue
}

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@
"access": "public"
},
"scripts": {
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
"verify": "yarn verify:ios && yarn verify:android && yarn verify:web",
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
"verify:android": "cd android && ./gradlew clean build test && cd ..",
"verify:web": "npm run build",
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
"verify:web": "yarn build",
"lint": "yarn eslint && yarn prettier --check && yarn swiftlint lint",
"fmt": "yarn eslint --fix && yarn prettier --write && yarn swiftlint --fix --format",
"eslint": "eslint . --ext ts",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"swiftlint": "swiftlint",
"docgen": "docgen --api NordicDfuPlugin --output-readme README.md --output-json dist/docs.json",
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
"build": "yarn clean && yarn docgen && tsc && rollup -c rollup.config.js",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"test": "echo \"No test specified\"",
"prepare": "husky install",
"prepublishOnly": "npm run build"
"prepublishOnly": "yarn build"
},
"devDependencies": {
"@capacitor/android": "^5.3.0",
Expand Down

0 comments on commit 2919c16

Please sign in to comment.