Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robingenz committed Mar 1, 2024
1 parent 8932191 commit eadaeb3
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 85 deletions.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':capawesome-team-capacitor-file-opener')
implementation project(':capawesome-team-capacitor-nfc')

}

Expand Down
8 changes: 6 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
</provider>
</application>

<!-- Permissions -->

<uses-permission android:name="android.permission.INTERNET" />
<!-- To get access to the NFC hardware. -->
<uses-permission android:name="android.permission.NFC" />
<!-- The minimum SDK version that your application can support. -->
<uses-sdk android:minSdkVersion="10"/>
<!-- (Optional) This will ensure that your app appears in Google Play only for devices with NFC hardware. -->
<uses-feature android:name="android.hardware.nfc" android:required="true" />
</manifest>
4 changes: 4 additions & 0 deletions android/app/src/main/assets/capacitor.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@
{
"pkg": "@capawesome-team/capacitor-file-opener",
"classpath": "io.capawesome.capacitorjs.plugins.fileopener.FileOpenerPlugin"
},
{
"pkg": "@capawesome-team/capacitor-nfc",
"classpath": "io.capawesome.capacitorjs.plugins.nfc.NfcPlugin"
}
]
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacit

include ':capawesome-team-capacitor-file-opener'
project(':capawesome-team-capacitor-file-opener').projectDir = new File('../node_modules/@capawesome-team/capacitor-file-opener/android')

include ':capawesome-team-capacitor-nfc'
project(':capawesome-team-capacitor-nfc').projectDir = new File('../node_modules/@capawesome-team/capacitor-nfc/android')
20 changes: 9 additions & 11 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
7C07B6D22B91FB6C00652B63 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -73,6 +74,7 @@
504EC3061FED79650016851F /* App */ = {
isa = PBXGroup;
children = (
7C07B6D22B91FB6C00652B63 /* App.entitlements */,
50379B222058CBB4000EE86E /* capacitor.config.json */,
504EC3071FED79650016851F /* AppDelegate.swift */,
504EC30B1FED79650016851F /* Main.storyboard */,
Expand Down Expand Up @@ -128,7 +130,7 @@
504EC3031FED79650016851F = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1100;
ProvisioningStyle = Manual;
ProvisioningStyle = Automatic;
};
};
};
Expand Down Expand Up @@ -345,19 +347,17 @@
baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = U73Q28Z596;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = U73Q28Z596;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = de.dhbw.vs.standortapp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match Development de.dhbw.vs.standortapp";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development de.dhbw.vs.standortapp";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -369,18 +369,16 @@
baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = U73Q28Z596;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = U73Q28Z596;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = de.dhbw.vs.standortapp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match AppStore de.dhbw.vs.standortapp";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore de.dhbw.vs.standortapp";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
10 changes: 10 additions & 0 deletions ios/App/App/App.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>TAG</string>
</array>
</dict>
</plist>
10 changes: 8 additions & 2 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<key>CFBundleVersion</key>
<key>CFBundleVersion</key>
<string>5.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
Expand All @@ -45,5 +45,11 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>NFCReaderUsageDescription</key>
<string>The app enables the reading and writing of various NFC tags.</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>D2760000850100</string>
</array>
</dict>
</plist>
3 changes: 2 additions & 1 deletion ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"webDir": "www",
"npmClient": "npm",
"server": {
"iosScheme": "ionic"
"iosScheme": "ionic",
"url": "http://192.168.2.112:8100"
},
"cordova": {
"preferences": {
Expand Down
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def capacitor_pods
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
pod 'CapawesomeTeamCapacitorFileOpener', :path => '../../node_modules/@capawesome-team/capacitor-file-opener'
pod 'CapawesomeTeamCapacitorNfc', :path => '../../node_modules/@capawesome-team/capacitor-nfc'
pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
end

Expand Down
10 changes: 8 additions & 2 deletions ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ PODS:
- Capacitor
- CapawesomeTeamCapacitorFileOpener (5.0.4):
- Capacitor
- CapawesomeTeamCapacitorNfc (5.1.0-dev.7d38c01.1709239536):
- Capacitor
- CordovaPlugins (5.6.0):
- CapacitorCordova

Expand All @@ -35,6 +37,7 @@ DEPENDENCIES:
- "CapacitorSplashScreen (from `../../node_modules/@capacitor/splash-screen`)"
- "CapacitorStatusBar (from `../../node_modules/@capacitor/status-bar`)"
- "CapawesomeTeamCapacitorFileOpener (from `../../node_modules/@capawesome-team/capacitor-file-opener`)"
- "CapawesomeTeamCapacitorNfc (from `../../node_modules/@capawesome-team/capacitor-nfc`)"
- CordovaPlugins (from `../capacitor-cordova-ios-plugins`)

EXTERNAL SOURCES:
Expand All @@ -60,6 +63,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/status-bar"
CapawesomeTeamCapacitorFileOpener:
:path: "../../node_modules/@capawesome-team/capacitor-file-opener"
CapawesomeTeamCapacitorNfc:
:path: "../../node_modules/@capawesome-team/capacitor-nfc"
CordovaPlugins:
:path: "../capacitor-cordova-ios-plugins"

Expand All @@ -75,8 +80,9 @@ SPEC CHECKSUMS:
CapacitorSplashScreen: dd3de3f3644710fa2a697cfb91ec262eece4d242
CapacitorStatusBar: f390fbb49b82ffb754ea4b3cf71dc8b048baf3e7
CapawesomeTeamCapacitorFileOpener: a635d36c142c95018855c21c102da07eb88a4e1e
CapawesomeTeamCapacitorNfc: 62f7b56f556612e050d95a1be2d459c55b02eaa3
CordovaPlugins: 51a49218c1b6e2ae7d7f40efa9159eb978ddc888

PODFILE CHECKSUM: 26c4df6714124140b8e56789f2c8fd87c2fef304
PODFILE CHECKSUM: baa07d86309c338c813d17409138037a1834285f

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ export class CapacitorNfcService {
return Nfc.transceive(options);
}

public connect(options: ConnectOptions): Promise<void> {
return Nfc.connect(options);
public async connect(options: ConnectOptions): Promise<void> {
const isAndroid = Capacitor.getPlatform() === 'android';
if (isAndroid) {
await Nfc.connect(options);
}
}

public async close(): Promise<void> {
await Nfc.close();
const isAndroid = Capacitor.getPlatform() === 'android';
if (isAndroid) {
await Nfc.close();
}
}

public async openSettings(): Promise<void> {
Expand Down
56 changes: 0 additions & 56 deletions src/app/core/services/nfc/nfc/nfc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,64 +30,24 @@ export class NfcService {
}

public async stopScanSession(): Promise<void> {
const isSupported = await this.isSupported();
if (!isSupported) {
return;
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
return;
}
await this.capacitorNfcService.stopScanSession();
}

public async write(message: NdefMessage): Promise<void> {
const isSupported = await this.isSupported();
if (!isSupported) {
throw this.createNotSupportedError();
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
throw this.createNotEnabledError();
}
await this.capacitorNfcService.write({
message,
});
}

public async erase(): Promise<void> {
const isSupported = await this.isSupported();
if (!isSupported) {
throw this.createNotSupportedError();
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
throw this.createNotEnabledError();
}
await this.capacitorNfcService.erase();
}

public async format(): Promise<void> {
const isSupported = await this.isSupported();
if (!isSupported) {
throw this.createNotSupportedError();
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
throw this.createNotEnabledError();
}
await this.capacitorNfcService.format();
}

public async transceive(techType: NfcTagTechType, data: number[]): Promise<number[]> {
const isSupported = await this.isSupported();
if (!isSupported) {
throw this.createNotSupportedError();
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
throw this.createNotEnabledError();
}
const { response } = await this.capacitorNfcService.transceive({
techType,
data,
Expand All @@ -96,28 +56,12 @@ export class NfcService {
}

public async connect(techType: NfcTagTechType): Promise<void> {
const isSupported = await this.isSupported();
if (!isSupported) {
throw this.createNotSupportedError();
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
throw this.createNotEnabledError();
}
await this.capacitorNfcService.connect({
techType,
});
}

public async close(): Promise<void> {
const isSupported = await this.isSupported();
if (!isSupported) {
return;
}
const isEnabled = await this.isEnabled();
if (!isEnabled) {
return;
}
await this.capacitorNfcService.close();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ion-header>
<ion-toolbar>
<ion-title>Wohnungsmarkt</ion-title>
<ion-title>Kartenguthaben</ion-title>
<ion-buttons slot="end">
<ion-button (click)="closeModal()">
<ion-icon name="close"></ion-icon>
Expand All @@ -12,10 +12,10 @@
<ion-content class="ion-padding">
<ion-card>
<ion-card-header>
<ion-card-title> Guthaben </ion-card-title>
<ion-card-title> Kartenguthaben </ion-card-title>
</ion-card-header>
<ion-card-content>
@if (balance()) {
@if (balance() !== undefined) {
<span>Dein aktuelles Guthaben beträgt:</span>
<div class="balance">
<h1>{{ balance() | currency: "EUR" : "symbol" : "1.2-2" : "de" }}</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class CanteenCardBalanceModalComponent {

public async startScanSession(): Promise<void> {
this.isScanSessionActive.set(true);
this.balance.set(undefined);
try {
await this.nfcService.startScanSession();
} catch (error) {
Expand Down Expand Up @@ -74,7 +75,8 @@ export class CanteenCardBalanceModalComponent {
// 4. Parse the balance
const balance = this.convertBytesToBalance(response);
this.balance.set(balance);
// 5. Stop the scan session
// 5. Close the connection
await this.nfcService.close();
} finally {
await this.stopScanSession();
}
Expand All @@ -88,6 +90,7 @@ export class CanteenCardBalanceModalComponent {
trimmedBytes.reverse();
const hex = this.nfcHelperService.convertBytesToHex(trimmedBytes);
const balance = this.nfcHelperService.convertHexToNumber(hex);
console.log({ bytes, trimmedBytes, hex, balance });
return balance;
}

Expand Down Expand Up @@ -116,9 +119,6 @@ export class CanteenCardBalanceModalComponent {
this.isScanSessionActive.set(false);
void this.activeWriterAlert?.dismiss();
this.cancelSubject.next(undefined);
await this.nfcService.close().catch(() => {
// Ignore errors
});
await this.nfcService.stopScanSession();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ion-list>
<ion-item button (click)="showCanteenCardBalanceModal()" [lines]="'none'">
<ion-label>Guthaben auslesen</ion-label>
<ion-label>Kartenguthaben</ion-label>
</ion-item>
</ion-list>
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export class CanteenMenuPopoverComponent {
await this.dialogService.showModal({
component: CanteenCardBalanceModalComponent,
});
await this.dialogService.dismissPopover();
}
}

0 comments on commit eadaeb3

Please sign in to comment.