Skip to content

Commit 532fe00

Browse files
Add instructions for running example app
Move useful information from CONTRIBUTING.md to the example-app/README.md
1 parent 357567b commit 532fe00

File tree

2 files changed

+69
-97
lines changed

2 files changed

+69
-97
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

example-app/README.md

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,74 @@
1-
## Created with Capacitor Create App
1+
### Running this example application
22

3-
This app was created using [`@capacitor/create-app`](https://github.com/ionic-team/create-capacitor-app),
4-
and comes with a very minimal shell for building an app.
3+
To run the provided example application, complete the following steps:
54

6-
### Running this example
5+
1. Clone the repository:
6+
```bash
7+
git clone https://github.com/salemove/widgets_sdk_ionic.git
8+
```
9+
2. Navigate to the project directory:
10+
```bash
11+
cd widgets_sdk_ionic
12+
```
13+
3. Install dependencies:
14+
```bash
15+
npm install
16+
```
17+
4. Build the SDK:
18+
```bash
19+
npm run build
20+
```
21+
5. Navigate to the example app directory:
22+
```bash
23+
cd example-app
24+
```
25+
6. Create the environment file and add your Glia credentials:
26+
- Create the file: `example-app/src/environments/environment.ts`.
27+
- Refer to the [How to use environment variables?](#how-to-use-environment-variables) section for the instructions on how to add your Glia credentials.
28+
7. Install dependencies for the example app:
29+
```bash
30+
npm install --legacy-peer-deps
31+
```
32+
8. Build the example app:
33+
```bash
34+
npm run build
35+
```
36+
9. Sync with Capacitor:
37+
```bash
38+
npx cap sync
39+
```
40+
10. Open the Android project (`widgets_sdk_ionic/example-app/android`) in Android Studio:
41+
- Sync the project with Gradle.
42+
- Run the Android app.
43+
11. Open the iOS project (`widgets_sdk_ionic/example-app/ios`) in Xcode:
44+
- Run the iOS app.
745

8-
To run the provided example, you can use `npm start` command.
46+
### How to use environment variables?
947

10-
```bash
11-
npm start
48+
- Create an `environments` folder inside the `src` folder, and then create the `environment.ts` file inside it: `example-app/src/environments/environment.ts`.
49+
- Add all environment variables to the `environment.ts` (replace the example values with your data):
50+
51+
```typescript
52+
export const environment = {
53+
IONIC_API_KEY: 'site-api-key',
54+
IONIC_API_SECRET: 'site-api-secret',
55+
IONIC_SITE_ID: 'site-identifier',
56+
IONIC_REGION: 'us',
57+
IONIC_COMPANY_NAME: 'IonicCompany',
58+
};
1259
```
60+
61+
After environment variables are defined:
62+
63+
1. Open the `example-app` folder.
64+
2. Run `npm run build`.
65+
3. Run `npx cap sync`.
66+
67+
ℹ️ Since Ionic is built on top of Angular, the example app project uses Angular’s built-in mechanism for managing environment variables. You can refer to the official Angular documentation [here](https://v17.angular.io/guide/build).
68+
69+
### Troubleshooting
70+
71+
To be sure that environment variables have been applied correctly, open the `public` folder and find the `index-#{some_hash}.js` file. If the variables were applied correctly, you should see something like this in Android Studio and Xcode, respectively:
72+
![image](/image/406754853-aff92ca8-14e1-4ba3-a89c-c20569880d55.png)
73+
![image](/image/406755039-3cf54cb1-fb3c-4eab-a494-3c92cb13cbfa.png)
74+

0 commit comments

Comments
 (0)