Download presentation
Presentation is loading. Please wait.
1
Randy Dalrymple HillyRoad, LLC
Android Messaging Randy Dalrymple HillyRoad, LLC
2
Initial Problem Our app depends on sending daily status (I'm OK)
Need to send status message between phones Must be cross-platform (Android/iOS) Cannot presume proximity (can be anywhere)
3
Prior Solution Android-only product works with SMS
Android exposes interface to SMS inbox + events Quick, easy, ROBUST solution Fails completely with iOS (SMS interface hidden) → Will not work cross-platform
4
Additional Constraints
Must not require application server (I don't have one) Must be low/no-cost RELIABILITY!
5
Options Considered Use Existing Solutions Dedicated server
SMS (works only with Android) WhatsApp/Telegram (no API available) Dedicated server Violates constraint → Discard
6
Options Considered (Cont)
Push Messaging Worth a look Other Chat Database
7
Mobile Push Messaging Internet-based
Each platform (Apple, Google, Microsoft, etc.) has its own dedicated server Google: Firebase Cloud Messaging (FCM) Apple: Apple Push Messaging Server (APNS) Messages sent synchronously to device (more or less) Messages can originate from anywhere (other device, server, console)
8
More Mobile Push Messaging
Often used for mass marketing/promotion Token provides device ID/app ID Payload is JSON dictionary format Relies on persistent, dedicated socket connection Google uses the Google Play Services socket for all services (Push, Maps, etc.) → Android device MUST have Google Play Services installed and running for push messaging
9
Google Firebase
10
Messaging Architecture
5 Application Server 5 Apple Push Notification Server (APN) Firebase/ Google Cloud Messaging Server 1 6 3 2 3 2 4 4 6 1 1. Register with messaging server 2. Receive token & connect to socket 3. Log in with token 4. Send push message 5. Request push notification 6. Receive push notification iOS Client Android Client
11
Application Server Role
Authenticate user Handle push token for device Determine appropriate push server Accept push request from device Request push notification from push server Can use HTTP or XMPP (Preferred by APNS) APNS requires secure, persistent connection Handle errors/retries
12
Find Application Server BaaS
Search criteria: Must provide complete solution Must be economical for small-scale deployment Should scale if product is successful Several products considered, but few are viable
13
Candidates Product Requires App Server Cost Satisfactory AWS Yes
Free/Low No Firebase + Patch Free Applozic High after 30 days PubNub $149/mo for >100 users Layer Low Magnet High after 90 days AZStack Urban Airship QuickBlox Free for <20K users
14
QuickBlox Messaging Part of communications suite supporting messaging, chat, video chat, etc. Company based in London, UK Free tier Up to 20K users Allows 20 msg/sec. Beyond that, data ignored Libraries/sample apps for Android, iOS
15
QuickBlox Messaging Implementation
Register application with Google, Apple Google is MUCH easier!!! Create QuickBlox account and register application Integrate QuickBlox framework in application
16
Google Console
17
QuickBlox Console
18
Problem 1: QB Integration Options
Bare web API Most efficient, but most work (threading, etc.) Use QB framework Must analyze/understand framework more fully Sample app (includes framework) Easiest to implement quickly → Use this one!
19
Problem 2: How to Handle User ID
QB User ID must be unique Users are unaware of underlying QB framework Users know each other only by name and phone number → Create anonymous QB User ID using phone number
20
Android QB Integration
Required app functions Test for internet connection Create user ID for QuickBlox framework Register for remote notification Retrieve recipients' user IDs when sending message Send push message Handle received push message
21
Push Sample App Integration
22
MainActivity @Override protected void onResume() { super.onResume(); try { if (!Utils.isNetworkConnected(getApplicationContext())) { Utils.showAlert("No Internet", "Check your internet connection.", MainActivity.this); } else { qbManager = new QBManager(this.getApplicationContext()); qbManager.createSession(); } } catch (Exception e) { // sometimes throws exception even when connected Utils.showAlert("No Internet", "Check your internet connection.", MainActivity.this); } mSharedPreferences = getSharedPreferences(Utils.PREFS, MODE_PRIVATE); String org = mSharedPreferences.getString(Utils.PREF_IS_ORGANIZER, null); if (org == "true") { createChatGroup(); } }
23
MainActivity
24
QBManager
25
MainActivity
26
MainActivity
27
CoreGcmPushListenerService
public abstract class CoreGcmPushListenerService extends GcmListenerService { private static final String TAG = CoreGcmPushListenerService.class.getSimpleName(); @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString(GcmConsts.EXTRA_GCM_MESSAGE); Log.v(TAG, "From: " + from); Log.v(TAG, "Message: " + message); if (ActivityLifecycle.getInstance().isBackground()) { showNotification(message); } logCheckInMessage(message); sendPushMessageBroadcast(message); protected abstract void showNotification(String message); protected abstract void sendPushMessageBroadcast(String message); protected abstract void logCheckInMessage(String message);
28
Results Messaging implemented in Android (appx. 35 hrs) and iOS (appx. 30 hrs) Successfully sent push messages between Android, iOS However
29
More Results Messaging not sufficiently reliable for safety/security application Google, Apple servers maintain 1-element queue per application iOS does not handle silent push cleanly During testing, Apple server offline for 24 hours We need to try something else—Chat, DB or something else!
30
Misc: QuickBlox Statistics
31
Misc: QuickBlox Console Push
32
Selected References
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.