Skip to content

Commit a09dc3d

Browse files
authored
Merge pull request #5 from Scode-Njnjas/bugfix/crash-when-install-on-ios
fix: crash when installed on ios
2 parents 5385df1 + 68ecb93 commit a09dc3d

17 files changed

+367
-76
lines changed

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
example/
2+
.github/
3+
.vscode/
4+
.yarn/
5+
.yarnrc.yml
6+
lefthook.yml
7+
babel.config.js
8+
tsconfig.json
9+
*.log

README.md

Lines changed: 109 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
A React Native SDK for ConvertedIn, providing easy integration of ConvertedIn's tracking and analytics features into your React Native application.
44

5-
## Installation
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/react-native-converted-in-sdk.svg)](https://badge.fury.io/js/react-native-converted-in-sdk) [![Downloads](https://img.shields.io/npm/dm/react-native-converted-in-sdk.svg)](https://www.npmjs.com/package/react-native-converted-in-sdk)
6+
7+
## 📹 Demo
8+
9+
![Watch the Demo](https://github.com/user-attachments/assets/15ff28dd-5039-4332-8e4a-5617bd4b4c66)
10+
11+
## 📦 Installation
612

713
Install the package using npm:
814

@@ -16,41 +22,104 @@ Or with yarn:
1622
yarn add react-native-converted-in-sdk
1723
```
1824

19-
## Usage
25+
### Follow these steps to complete the installation:
26+
27+
#### iOS
28+
29+
- Add `ConvertedinMobileSDK` to your `Podfile`:
30+
31+
```ruby
32+
pod 'react-native-converted-in-sdk', :path => '../node_modules/react-native-converted-in-sdk'
33+
```
34+
35+
- Run `pod install` inside the `ios` directory.
36+
37+
#### Android
38+
39+
- Add the following line to the `android/settings.gradle` file:
40+
41+
```gradle
42+
include ':react-native-converted-in-sdk'
43+
project(':react-native-converted-in-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-converted-in-sdk/android')
44+
```
45+
46+
- Add the following line to the `android/app/build.gradle` file:
47+
48+
```gradle
49+
implementation project(':react-native-converted-in-sdk')
50+
```
51+
52+
- Sync your project with Gradle files by running:
53+
54+
```bash
55+
./gradlew sync
56+
```
57+
58+
## 🚀 Usage
59+
60+
### Manual Module Usage
61+
62+
1. **Import the module and initialize it in the root of your app:**
63+
64+
```jsx
65+
import { initializeSDK } from 'react-native-converted-in-sdk';
66+
67+
initializeSDK({
68+
pixelId: 'your_pixel_id',
69+
storeUrl: 'your_store_url',
70+
});
71+
```
72+
73+
2. **Use the SDK methods in your components:**
74+
75+
```jsx
76+
import { identifyUser } from 'react-native-converted-in-sdk';
77+
78+
const Component = () => {
79+
React.useEffect(() => {
80+
// Example usage of SDK functions
81+
identifyUser("test@test.com", "+91", "9876543210");
82+
}, []);
83+
84+
// Your component logic here
85+
};
86+
```
87+
88+
### Usage with Hook
2089

2190
1. **Wrap your app with `RNConvertInSDKProvider`:**
2291

23-
```jsx
24-
export default function App() {
25-
return (
26-
<RNConvertInSDKProvider
27-
pixelId="your_pixel_id"
28-
storeUrl="your_store_url"
29-
>
30-
<AppContent />
31-
</RNConvertInSDKProvider>
32-
);
33-
}
34-
```
92+
```jsx
93+
export default function App() {
94+
return (
95+
<RNConvertInSDKProvider
96+
pixelId="your_pixel_id"
97+
storeUrl="your_store_url"
98+
>
99+
<AppContent />
100+
</RNConvertInSDKProvider>
101+
);
102+
}
103+
```
35104

36-
2. **Use the `useConvertedIn` hook in your components:**
105+
2. **Use the `useConvertedInSdk` hook in your components:**
37106

38-
```jsx
39-
import { useConvertedIn } from 'react-native-converted-in-sdk';
107+
```jsx
108+
import { useConvertedInSdk } from 'react-native-converted-in-sdk';
40109
41-
const AppContent = () => {
42-
const { initializeSDK } = useConvertedIn();
110+
const Component = () => {
111+
const { identifyUser } = useConvertedInSdk();
43112
44-
React.useEffect(() => {
45-
// Example usage of SDK functions
46-
initializeSDK();
47-
}, [initializeSDK]);
113+
React.useEffect(() => {
114+
// Example usage of SDK functions
115+
identifyUser("test@test.com", "+91", "9876543210");
116+
}, []);
48117
49-
// Your component logic here
50-
};
51-
```
118+
// Your component logic here
119+
};
120+
```
52121

53-
## API Reference
122+
## 📚 API Reference
54123

55124
### `RNConvertInSDKProvider`
56125

@@ -59,7 +128,7 @@ const AppContent = () => {
59128
| `pixelId` | string | Yes | Your ConvertedIn pixel ID |
60129
| `storeUrl` | string | Yes | Your store URL |
61130

62-
### `useConvertedIn`
131+
### `useConvertedInSdk`
63132

64133
Returns an object with the following methods:
65134

@@ -68,9 +137,9 @@ Returns an object with the following methods:
68137
| `isInitialized` | None | `boolean` | Returns whether the SDK has been initialized. |
69138
| `initializeSDK` | `config: { pixelId: string, storeUrl: string }` | `Promise<void>` | Initializes the SDK with the provided configuration. Call this as early as possible in your app's lifecycle. |
70139
| `identifyUser` | `email: string, countryCode: string, phoneNumber: string` | `void` | Identifies a user with their email, country code, and phone number. This helps in tracking user-specific events and improving personalization. |
71-
| `addEvent` | `eventName: string, currency: string, total: number, products: Product[]` | `void` | Adds a custom event with the specified name, currency, total, and products. This allows tracking of specific actions or milestones in your app. |
140+
| `addEvent` | `eventName: string, currency: string, total: number, products: Product[]` | `void` | Adds a custom event with the specified name, currency, total, and products. This allows tracking specific actions or milestones in your app. |
72141
| `viewContentEvent` | `currency: string, total: number, products: Product[]` | `void` | Tracks a view content event when a user views a product or content page. Includes details like currency, total value, and viewed products. |
73-
| `addToCartEvent` | `currency: string, total: number, products: Product[]` | `void` | Tracks an add to cart event when a user adds items to their shopping cart. Includes details about the added products, total value, and currency. |
142+
| `addToCartEvent` | `currency: string, total: number, products: Product[]` | `void` | Tracks an add-to-cart event when a user adds items to their shopping cart. Includes details about the added products, total value, and currency. |
74143
| `initiateCheckoutEvent` | `currency: string, total: number, products: Product[]` | `void` | Tracks the initiation of the checkout process. This event should be called when a user starts the purchasing process. |
75144
| `purchaseEvent` | `currency: string, total: number, products: Product[]` | `void` | Tracks a completed purchase event. This should be called when a user successfully completes a transaction, including details of purchased products. |
76145
| `registerEvent` | None | `void` | Tracks a user registration event. This should be called when a new user creates an account in your app. |
@@ -83,23 +152,23 @@ Returns an object with the following methods:
83152
| `quantity` | number | The quantity of the product. |
84153
| `name` | string | The name of the product. |
85154
86-
## Example
155+
## 🧪 Sample App
87156
88157
Check the `example` folder for a complete implementation example.
89158
90159
> [!NOTE]
91160
> If you encounter an error while installing pods in `example/ios`, please refer to this solution: [https://stackoverflow.com/a/78874710/12355129](https://stackoverflow.com/a/78874710/12355129)
92161
93-
## Development
162+
## 🛠️ Development
94163
95164
To develop the SDK locally:
96165
97-
1. Clone the repository
166+
1. Clone the repository.
98167
2. Ensure you have the following environment set up:
99168
- Node.js version 18 or higher.
100-
- Yarn version 3 or higher; the version fixed with the project is 3.6.1.
169+
- Yarn version 3 or higher (project version: 3.6.1).
101170
- Java 17 or higher.
102-
- For iOS development: Xcode 12.0 or higher.
171+
- For iOS development: Xcode 12.0 or higher. iOS deployment target 13.0 or higher.
103172
- For Android development: Android Studio 4.0 or higher.
104173
105174
3. Install dependencies:
@@ -123,15 +192,15 @@ To develop the SDK locally:
123192
yarn example android
124193
```
125194
126-
## Testing
195+
## 🧪 Testing
127196
128197
Run tests with:
129198
130199
```bash
131200
yarn test
132201
```
133202
134-
### Error Handling
203+
## 🚨 Error Handling
135204
136205
If any SDK method is called before initialization, an error will be thrown with the message:
137206
@@ -141,17 +210,17 @@ SDK must be initialized before calling this method.
141210
142211
Make sure to initialize the SDK using the `initializeSDK` method before invoking any other SDK methods.
143212
144-
## Contributing
213+
## 🤝 Contributing
145214
146215
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
147216
148-
## Official Documentation
217+
## 📚 Official Documentation
149218
150219
For detailed information and advanced usage, refer to the official ConvertedIn SDK documentation:
151220
152221
- [Android Getting Started Guide](https://developer.converted.in/android/getting-started)
153222
- [iOS Getting Started Guide](https://developer.converted.in/ios/getting-started)
154223
155-
## License
224+
## 📜 License
156225
157226
MIT

example/Gemfile.lock

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.7)
5+
base64
6+
nkf
7+
rexml
8+
activesupport (7.2.1)
9+
base64
10+
bigdecimal
11+
concurrent-ruby (~> 1.0, >= 1.3.1)
12+
connection_pool (>= 2.2.5)
13+
drb
14+
i18n (>= 1.6, < 2)
15+
logger (>= 1.4.2)
16+
minitest (>= 5.1)
17+
securerandom (>= 0.3)
18+
tzinfo (~> 2.0, >= 2.0.5)
19+
addressable (2.8.7)
20+
public_suffix (>= 2.0.2, < 7.0)
21+
algoliasearch (1.27.5)
22+
httpclient (~> 2.8, >= 2.8.3)
23+
json (>= 1.5.1)
24+
atomos (0.1.3)
25+
base64 (0.2.0)
26+
bigdecimal (3.1.8)
27+
claide (1.1.0)
28+
cocoapods (1.15.2)
29+
addressable (~> 2.8)
30+
claide (>= 1.0.2, < 2.0)
31+
cocoapods-core (= 1.15.2)
32+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
33+
cocoapods-downloader (>= 2.1, < 3.0)
34+
cocoapods-plugins (>= 1.0.0, < 2.0)
35+
cocoapods-search (>= 1.0.0, < 2.0)
36+
cocoapods-trunk (>= 1.6.0, < 2.0)
37+
cocoapods-try (>= 1.1.0, < 2.0)
38+
colored2 (~> 3.1)
39+
escape (~> 0.0.4)
40+
fourflusher (>= 2.3.0, < 3.0)
41+
gh_inspector (~> 1.0)
42+
molinillo (~> 0.8.0)
43+
nap (~> 1.0)
44+
ruby-macho (>= 2.3.0, < 3.0)
45+
xcodeproj (>= 1.23.0, < 2.0)
46+
cocoapods-core (1.15.2)
47+
activesupport (>= 5.0, < 8)
48+
addressable (~> 2.8)
49+
algoliasearch (~> 1.0)
50+
concurrent-ruby (~> 1.1)
51+
fuzzy_match (~> 2.0.4)
52+
nap (~> 1.0)
53+
netrc (~> 0.11)
54+
public_suffix (~> 4.0)
55+
typhoeus (~> 1.0)
56+
cocoapods-deintegrate (1.0.5)
57+
cocoapods-downloader (2.1)
58+
cocoapods-plugins (1.0.0)
59+
nap
60+
cocoapods-search (1.0.1)
61+
cocoapods-trunk (1.6.0)
62+
nap (>= 0.8, < 2.0)
63+
netrc (~> 0.11)
64+
cocoapods-try (1.2.0)
65+
colored2 (3.1.2)
66+
concurrent-ruby (1.3.4)
67+
connection_pool (2.4.1)
68+
drb (2.2.1)
69+
escape (0.0.4)
70+
ethon (0.16.0)
71+
ffi (>= 1.15.0)
72+
ffi (1.17.0)
73+
fourflusher (2.3.1)
74+
fuzzy_match (2.0.4)
75+
gh_inspector (1.1.3)
76+
httpclient (2.8.3)
77+
i18n (1.14.5)
78+
concurrent-ruby (~> 1.0)
79+
json (2.7.2)
80+
logger (1.6.1)
81+
minitest (5.25.1)
82+
molinillo (0.8.0)
83+
nanaimo (0.3.0)
84+
nap (1.1.0)
85+
netrc (0.11.0)
86+
nkf (0.2.0)
87+
public_suffix (4.0.7)
88+
rexml (3.3.7)
89+
ruby-macho (2.5.1)
90+
securerandom (0.3.1)
91+
typhoeus (1.4.1)
92+
ethon (>= 0.9.0)
93+
tzinfo (2.0.6)
94+
concurrent-ruby (~> 1.0)
95+
xcodeproj (1.25.0)
96+
CFPropertyList (>= 2.3.3, < 4.0)
97+
atomos (~> 0.1.3)
98+
claide (>= 1.0.2, < 2.0)
99+
colored2 (~> 3.1)
100+
nanaimo (~> 0.3.0)
101+
rexml (>= 3.3.2, < 4.0)
102+
103+
PLATFORMS
104+
ruby
105+
106+
DEPENDENCIES
107+
activesupport (>= 6.1.7.5, != 7.1.0)
108+
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
109+
110+
RUBY VERSION
111+
ruby 3.3.4p94
112+
113+
BUNDLED WITH
114+
2.5.18

0 commit comments

Comments
 (0)