- Introduction
- Getting Started
- Project Structure
- Development
- Setup invoke app
- Resources
- Flow call about app
- This app is React Native project.
- Can allow this app invoked by the BrekekePhone app and vice versa (with
Linking
). - Can allow sending data to the BrekekePhone app to auto-login and make calls.
- Node.js 20, with nvm recommendation
- JDK 17, with jenv recommendation
- yarn
- React Native CLI
- Xcode (for iOS development)
- Android Studio (for Android development)
- React Native - Environment Setup
- Clone the repository:
git clone https://github.com/brekekesoftware/brekekephone-invoke-example.git
- Navigate to the project directory:
cd brekekephone-invoke-example
- Install dependencies:
yarn install
/src
: Contains the source code of the React Native app./components
: Reusable React components./config.ts
: Contains const account to make auto login to the BrekekePhone app./icons.ts
: Contains icons used in the app./colors.ts
: Contains colors common used in the app./store
: Contains the configs stored to save data storage.
/android
and/ios
: Platform-specific files for Android and iOS.
First, you will need to start Metro, the JavaScript bundler that ships with React Native.
To start Metro, run the following command from the root of your React Native project:
yarn start
# OR with port
yarn start --port PORT
Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your app:
- Android
yarn android
# OR with port
yarn android --port PORT
- iOS
yarn ios
# OR with port
yarn ios --port PORT
Note: If you run the Metro server command with a port, please also run the app command with that port.
In /android/app/main/AndroidManifest.xml
file, add <intent-filter>
tag contains these elements and attribute values:
<action>
: This tag is used to point out which action will trigger an Intent. We will useandroid.intent.action.VIEW
to define an action to view app.<category>
: A string containing additional information about the kind of component that should handle the intent. We will useandroid.intent.category.DEFAULT
to receive implicit intents.<data>
: This tag provide attributes to define type of data of a URI. We will useandroid:scheme
andandroid:host
to define. The final URI will have the format:<scheme>://<host>
, it is used withLinking
.
- Use
Linking.openUrl(`brekekephonedev://open?${params}`)
to invoke this app, in which:- The
brekekephonedev
is the attributeandroid:scheme
in tag<data>
inAndroidmanifest.xml
file. - The
open
is the attributeandroid:host
in tag<data>
inAndroidmanifest.xml
file. - The variable
params
is data stringified byqs.stringify()
to send to the BrekekePhone app and contains the account info to make auto-login.
- The
- Use
Linking.addEventListener('url', callback)
when the app is foregrounded, the app is already open to get data fromcallback
. - Use
Linking.getInitialURL()
when app is not already open. - Install
qs
package usage query string parsing and stringifying. - Use
qs.parse()
to parse params from theurl
.
Linking
is only used with React Native. If you want to handle it with an Android code, you can follow the link below:
- The main UI has a button
Call
. After pressing it, will show a pop-up that has 2 options:Make call
:- This option will invoke the BrekekePhone app and call to the destination number defined in Settings.
- If not exist a destination number, this option will disabled.
- To change the destination number, please press on icon "Settings", type destination and press icon "Save".
- After the end call, will back to this app.
Open keypad
:- This option will link to the BrekekePhone app and open the keypad to type the number to call.
- After pressing a number phone and pressing the button
Call
. - Need login a account with option
PHONE
is Phone 2 -> 4 to receive call.
- To make call need login first on the BrekekePhone app.