@oobit/react-native-sdk 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,155 +0,0 @@
1
- /**
2
- * Wallet Integration Utilities
3
- * Handles opening Apple Wallet (iOS) and Google Wallet (Android)
4
- */
5
-
6
- import { Alert, Linking, Platform } from "react-native";
7
- import { WALLET_URLS } from "./types";
8
-
9
- /**
10
- * Opens the native wallet app based on platform
11
- * @returns Promise that resolves when wallet opens successfully
12
- */
13
- export const openNativeWallet = async (): Promise<boolean> => {
14
- try {
15
- if (Platform.OS === "ios") {
16
- return await openAppleWallet();
17
- } else if (Platform.OS === "android") {
18
- return await openGoogleWallet();
19
- } else {
20
- console.warn("Wallet opening not supported on this platform");
21
- return false;
22
- }
23
- } catch (error) {
24
- console.error("Failed to open wallet:", error);
25
- Alert.alert(
26
- "Error",
27
- "Could not open wallet. Please check if the app is installed."
28
- );
29
- return false;
30
- }
31
- };
32
-
33
- /**
34
- * Opens Apple Wallet on iOS
35
- * Uses multiple URL schemes in order of reliability
36
- */
37
- const openAppleWallet = async (): Promise<boolean> => {
38
- const { passkit, fallback } = WALLET_URLS.ios;
39
-
40
- try {
41
- console.log("Attempting to open Apple Wallet...");
42
-
43
- // Method 1: Try wallet:// scheme (documented as working in recent iOS)
44
- try {
45
- const canOpenWallet = await Linking.canOpenURL("wallet://");
46
- if (canOpenWallet) {
47
- await Linking.openURL("wallet://");
48
- console.log("Successfully opened Apple Wallet via wallet:// scheme");
49
- return true;
50
- }
51
- } catch (walletError) {
52
- console.log("wallet:// scheme failed, trying shoebox://:", walletError);
53
- }
54
-
55
- // Method 2: Try shoebox:// scheme (undocumented but widely used)
56
- // Note: This is unofficial and could potentially cause App Store rejection
57
- try {
58
- const canOpenShoebox = await Linking.canOpenURL(passkit);
59
- if (canOpenShoebox) {
60
- await Linking.openURL(passkit);
61
- console.log("Successfully opened Apple Wallet via shoebox:// scheme");
62
- return true;
63
- }
64
- } catch (shoeboxError) {
65
- console.log("shoebox:// scheme failed:", shoeboxError);
66
- }
67
-
68
- // Method 3: Fallback to wallet.apple.com (opens in browser)
69
- console.log("Direct schemes failed, falling back to web URL");
70
- const canOpenFallback = await Linking.canOpenURL(fallback);
71
- if (canOpenFallback) {
72
- await Linking.openURL(fallback);
73
- console.log("Opened wallet.apple.com in browser");
74
- return true;
75
- }
76
-
77
- throw new Error("Apple Wallet not available");
78
- } catch (error) {
79
- console.error("Failed to open Apple Wallet:", error);
80
- throw error;
81
- }
82
- };
83
-
84
- /**
85
- * Opens Google Wallet on Android
86
- * Uses Linking API to launch the app or fall back to Play Store
87
- */
88
- const openGoogleWallet = async (): Promise<boolean> => {
89
- const GOOGLE_WALLET_PACKAGE = "com.google.android.apps.walletnfcrel";
90
-
91
- try {
92
- console.log("Attempting to open Google Wallet...");
93
-
94
- // Try using the market:// scheme to launch the app if it's installed
95
- try {
96
- const canOpen = await Linking.canOpenURL(`market://launch?id=${GOOGLE_WALLET_PACKAGE}`);
97
- console.log("Can open market launch URL:", canOpen);
98
-
99
- if (canOpen) {
100
- await Linking.openURL(`market://launch?id=${GOOGLE_WALLET_PACKAGE}`);
101
- console.log("Successfully opened Google Wallet via market:// scheme");
102
- return true;
103
- }
104
- } catch (marketLaunchError) {
105
- console.log("Market launch failed:", marketLaunchError);
106
- }
107
-
108
- // App is not installed or market:// not available, open Play Store
109
- console.log("Opening Play Store to install Google Wallet");
110
- try {
111
- // Try native Play Store app first
112
- const playStoreUrl = `market://details?id=${GOOGLE_WALLET_PACKAGE}`;
113
- await Linking.openURL(playStoreUrl);
114
-
115
- Alert.alert(
116
- "Google Wallet",
117
- "Google Wallet is not installed. Opening Play Store to install the app."
118
- );
119
- return false;
120
- } catch (marketError) {
121
- console.log("Market URL failed, trying web Play Store:", marketError);
122
-
123
- // Fallback to web Play Store
124
- await Linking.openURL(
125
- `https://play.google.com/store/apps/details?id=${GOOGLE_WALLET_PACKAGE}`
126
- );
127
-
128
- Alert.alert(
129
- "Google Wallet",
130
- "Google Wallet is not installed. Opening Play Store to install the app."
131
- );
132
- return false;
133
- }
134
- } catch (error) {
135
- console.error("Failed to open Google Wallet:", error);
136
- throw error;
137
- }
138
- };
139
-
140
- /**
141
- * Check if wallet is available on the current platform
142
- */
143
- export const isWalletAvailable = async (): Promise<boolean> => {
144
- try {
145
- if (Platform.OS === "ios") {
146
- return await Linking.canOpenURL(WALLET_URLS.ios.passkit);
147
- } else if (Platform.OS === "android") {
148
- return await Linking.canOpenURL(WALLET_URLS.android.googlePay);
149
- }
150
- return false;
151
- } catch (error) {
152
- console.error("Error checking wallet availability:", error);
153
- return false;
154
- }
155
- };