Ionic कैप्चर
लोकल Capacitor plugin के साथ Ionic ऐप से कैप्चर खोलें।
आपका बैक-एंड Human Plugin में Journey flow और ऐसे callbackUri के साथ process बनाता है जो आपके ऐप की URL scheme का उपयोग करता है। एक लोकल Capacitor plugin जवाब के link को Android पर Custom Tabs में और iOS पर ASWebAuthenticationSession में खोलता है। कैप्चर समाप्त होने पर plugin resolve होता है और ऐप आगे का काम संभाल लेता है।
create के जवाब से Human Plugin का id रखें। आपका बैक-एंड उसी से नतीजा पढ़ता है।
पूर्वापेक्षाएं
- Capacitor 4 या बाद के साथ Ionic
- Xcode 14 या बाद का, और Android Studio
- आपके ऐप की अपनी यूनीक URL scheme, जैसे
myapp
1. अपनी scheme के साथ process बनाएं
आपका बैक-एंड scheme को callbackUri के रूप में भेजता है:
{
"flow": "humantoken",
"clientId": "client-a",
"correlationId": "order-1001",
"credential": { "type": "DUI_TYPE_NG_BVN", "value": "<document number>" },
"callbackUri": "myapp://callback"
}
और id तथा link ऐप को लौटाता है।
2. plugin इंटरफ़ेस परिभाषित करें
// src/plugins/capture-plugin.ts
import { registerPlugin } from '@capacitor/core';
export interface CapturePlugin {
openSession(options: { url: string }): Promise<{ callbackUrl: string }>;
}
const Capture = registerPlugin<CapturePlugin>('CapturePlugin');
export default Capture;