Skip to content

Commit

Permalink
feat: setup for iOS
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
Berend Sliedrecht committed Jan 7, 2025
1 parent 977c6b0 commit 7e0190f
Show file tree
Hide file tree
Showing 19 changed files with 1,710 additions and 3,486 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ android.iml
android/app/libs
android/keystores/debug.keystore

# Cocoapods
example/ios/Pods

# Ruby
example/vendor/

# node.js
node_modules/
npm-debug.log
Expand Down
38 changes: 35 additions & 3 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli
# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts
# @end expo-cli

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

app-example
1 change: 1 addition & 0 deletions example/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-linker=hoisted
36 changes: 18 additions & 18 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{
"expo": {
"name": "mdoc-data-transfer-example",
"slug": "mdoc-data-transfer-example",
"name": "expo-mdoc-data-transfer-example",
"slug": "expo-mdoc-data-transfer-example",
"version": "1.0.0",
"orientation": "portrait",
"scheme": "mdoc-data-transfer-example",
"userInterfaceStyle": "automatic",
"icon": "./assets/images/icon.png",
"scheme": "myapp",
"splash": {
"image": "./assets/images/splash.png"
},
"ios": {
"bundleIdentifier": "id.animo.expo-mdoc-data-transfer-example"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "id.animo.expomdocdatatransferexample"
},
"plugins": [
"../app.plugin.js",
[
"expo-build-properties",
{
Expand All @@ -18,18 +30,6 @@
}
}
]
],
"experiments": {
"typedRoutes": true
},
"android": {
"package": "id.animo.mdocdatatransfer.example"
},
"ios": {
"bundleIdentifier": "id.animo.mdocdatatransfer.example"
},
"splash": {
"backgroundColor": "#ffffff"
}
]
}
}
49 changes: 3 additions & 46 deletions example/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
import { mdocDataTransfer, useMdocDataTransferShutdownOnUnmount } from '@animo-id/expo-mdoc-data-transfer'
import { useEffect, useState } from 'react'
import { Button, Platform, View } from 'react-native'
import { type Permission, PermissionsAndroid } from 'react-native'

import QrCode from 'react-native-qrcode-svg'

const Pad = () => <View style={{ marginBottom: 10 }} />

const PERMISSIONS = [
'android.permission.ACCESS_FINE_LOCATION',
'android.permission.BLUETOOTH_CONNECT',
'android.permission.BLUETOOTH_SCAN',
'android.permission.BLUETOOTH_ADVERTISE',
'android.permission.ACCESS_COARSE_LOCATION',
] as const as Permission[]

const requestPermissions = async () => PermissionsAndroid.requestMultiple(PERMISSIONS)
import { Text, View } from 'react-native'

export const App = () => {
const [qrCode, setQrCode] = useState<string>()

useMdocDataTransferShutdownOnUnmount()

const startEngagement = async () => {
const mdt = mdocDataTransfer.instance()
const qr = await mdt.startQrEngagement()
mdt.enableNfc()
await mdt.sendDeviceResponse(new Uint8Array([1, 2, 3]))
setQrCode(qr)
await mdt.waitForDeviceRequest()
console.log('--- convert device request into a device response ---')
await mdt.sendDeviceResponse(new Uint8Array())
mdt.shutdown()
}

const shutdown = () => {
mdocDataTransfer.instance().shutdown()
}

return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
{Platform.OS === 'android' && <Button title="request permissions" onPress={requestPermissions} />}
<Pad />
<Button title="start engagement" onPress={startEngagement} />
<Pad />
<Button title="shutdown" onPress={shutdown} />
<Pad />
{qrCode && <QrCode value={qrCode} size={300} />}
<View>
<Text>Hello</Text>
</View>
)
}
File renamed without changes.
Binary file added example/assets/images/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/assets/images/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions example/babel.config.js

This file was deleted.

34 changes: 0 additions & 34 deletions example/metro.config.js

This file was deleted.

41 changes: 19 additions & 22 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
{
"name": "mdoc-data-transfer-example",
"main": "app/index.tsx",
"version": "0.0.0",
"name": "expo-mdoc-data-transfer-example",
"main": "app/index.js",
"version": "1.0.0",
"scripts": {
"start": "expo start -c --dev-client",
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"prebuild": "expo prebuild --no-install"
"prebuild": "expo prebuild"
},
"dependencies": {
"@animo-id/expo-mdoc-data-transfer": "../",
"@babel/runtime": "^7.25.9",
"expo": "~51.0.38",
"expo-build-properties": "~0.12.5",
"expo-dev-client": "~4.0.28",
"react": "18.2.0",
"react-native": "0.74.5",
"react-native-gesture-handler": "2.16.2",
"react-native-qrcode-svg": "^6.3.12",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0"
"expo": "~52.0.23",
"expo-build-properties": "~0.13.1",
"react": "18.3.1",
"react-native": "0.76.5",
"react-native-gesture-handler": "~2.20.2",
"react-native-reanimated": "~3.16.1",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-web": "~0.19.13",
"react-native-webview": "13.12.5"
},
"devDependencies": {
"@babel/core": "7.24.7",
"@react-native-community/cli": "^14.1.1",
"@types/react": "18.2.79",
"typescript": "5.3.3"
"@babel/core": "^7.25.2",
"@types/react": "~18.3.12",
"typescript": "^5.3.3"
},
"expo": {
"autoLinking": {
"autolinking": {
"nativeModulesDir": ".."
}
},
Expand Down
Loading

0 comments on commit 7e0190f

Please sign in to comment.