The Android Mac Connector project aims to bridge the connectivity between Android and Mac devices. Equipped with MQTT, you can send and read SMS, receive app notifications and take photos to your Android device from your Mac without sacrificing battery power. In addition, they can continue to remain connected even on different networks! Best of all, you can host this project on your own Firebase infrastructure for free (as at the time of writing)!
This project consists of a Kotlin-written Android app, a SwiftUI app, a MQTT broker, and a REST Api server written in TypeScript. A video of the project can be seen below:
This is the system architecture of the project:
The technologies behind this project first relies on an MQTT connection to establish a two-way communication between a device and the server while guaranteeing message delivery and low power consumption.
However, keeping an MQTT connection open is problematic for Android and Mac devices as the OS tend to terminate background services (thereby closing our MQTT connections). This is in the their effort to save battery power. Hence, the project depends on Push Notification Services to send updates from the server to the device, allowing us to re-establish the MQTT connection if needed. The push notification services this project currently uses is Firebase Messaging, which is used to send push notifications to the Android device. We are hoping to use APNs to send updates to the Mac device.
In addition, this project consists of a RESTful Web Api to query the registered devices a user has. Registered devices are stored in Firestore.
Lastly, this project utilizes Firebase Authentication Service to authenticate MQTT / HTTP connections, and register new users.
Required programs and tools:
- Android studio
- XCode
- CocoaPods
- Google account
- Log into your Google Account and go to the Firebase Console
- Create a new project
- Set up Firestore in test mode by following the Create a Cloud Firestore database section of this wiki
- Set up Firebase Auth by going to the console, selecting Authentication, and enabling Email/Password
-
Put the credentials file in the server project's root directory by:
- Go to your GCP Console
- Select your project
- Create a custom role with
cloudmessaging.messages.createandfirebaseauth.users.getpermissions - Create a new service account with the role you have made from (3) and with the
Cloud Datastore Userrole - Under the service account, create a new key (in JSON format), and save it as
service-account-file.jsonin the project's root directory
-
Export the path of the credentials file to an environment variable
export GOOGLE_APPLICATION_CREDENTIALS=service-account-file.json -
[Optional] You can ignore authentication and authorization during MQTT connections by setting these environment variables:
export VERIFY_AUTHENTICATION=false export VERIFY_AUTHORIZATION=false -
Run the server by running
$ npm start. It should spawn up a new server process under port 3000
-
Open the
android-appfolder in Android Studio -
Add the Android app to Firebase by:
- Go to the Firebase Console, click on Add App, select Android,
- Set the package name to
com.androidmacconnector.androidapp - Download the
google-services.jsonconfig file to the Android app project's app directory - Skip the Add Firebase SDK step
-
Build and run the project in Android Studio by clicking on the green arrow button. It should succeed
-
Run
$ pod installin the project's root directory -
Open
./mac-catalyst-app/Mac Catalyst App.xcworkspacein XCode -
Add the SwiftUI app to Firebase by:
- Go to the Firebase Console, click on Add App, select iOS,
- Set the iOS bundle ID to
com.androidmacconnector.Mac-Catalyst-App - Download the
GoogleService-Info.plistconfig file to the Mac Catalyst project - Skip the Add Firebase SDK and Add Initialization Code steps
-
In XCode, set the device to run the app on to Mac
-
Build and run the project in XCode by clicking on the arrow button. It should succeed
Please note that this project is used for educational purposes and is not intended to be used commercially. We are not liable for any damages/changes done by this project.
Emilio Kartono, who made the entire project
This project is protected under the GNU licence. Please refer to the Licence.txt for more information.

