Receive Push Notifications
- iOS
- Android
- React Native
-
Add your iOS app on Firebase Console:
Project Overview > Add App > iOS -
Download
GoogleService-Info.plist -
Add
GoogleService-Info.plistto the Xcode project (Add Files…, enable Copy items if needed). Select the plist in the Project Navigator, open the File Inspector (right sidebar, first tab), and under Target Membership check only your main application target—the target that produces your runnable app (usually named like your app). That tells Xcode to copy the plist into that app’s bundle so Firebase can load it. Do not check unrelated targets (e.g. tests or extensions) unless you intentionally use Firebase there too. -
Add the DashX packages: in Xcode go to File → Add Package Dependencies…, enter
https://github.com/dashxhq/dashx-ios.git, then add both DashX and DashXFirebase to your app target.infoThe CocoaPods
DashXpod ships the core library only.DashXFirebase(includingDashXAppDelegate) is provided via Swift Package Manager from the same repository. -
Add Firebase for iOS (for example
pod 'FirebaseMessaging'in your Podfile and runpod install, or add the Firebase iOS SDK via Swift Package Manager). EnsureFirebaseApp.configure()runs before you rely on FCM. -
Implement
DashXAppDelegate
import DashXFirebase
import FirebaseCore
import FirebaseMessaging
@main
class AppDelegate: DashXAppDelegate {
// ...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
DashX.configure(
withPublicKey: "YOUR_PUBLIC_KEY"
)
// Initialize Firebase and FCM
FirebaseApp.configure()
Messaging.messaging().delegate = self
// Request permission for push notifications and handle the resulting authorization status
DashX.requestNotificationPermission { authorizationStatus in
switch authorizationStatus {
case .authorized:
// User has granted permission for push notifications
case .denied:
// User has denied permission for push notifications
case .notDetermined:
// User has not yet made a choice about push notifications
case .provisional:
// User has granted provisional permission for push notifications (iOS 12+)
@unknown default:
// Handle any future authorization status not accounted for in the switch statement
}
}
// This method registers the device token with DashX
DashX.subscribe()
return true
}
override func notificationDeliveredInForeground(message: [AnyHashable: Any]) -> UNNotificationPresentationOptions {
print("\n=== Notification Delivered In Foreground ===\n")
print(message)
print("\n=================================================\n")
// This is how you want to show your notification in the foreground
// You can pass "[]" to not show the notification to the user or
// handle this with your own custom styles
return [.sound, .alert, .badge]
}
override func notificationClicked(message: [AnyHashable: Any], actionIdentifier: String) {
print("\n=== Notification Clicked ===\n")
print(message)
// Get the required data from the notification message
let userId = message["USER_ID"] as! String
// Perform the task associated with the action.
switch actionIdentifier {
case "ACCEPT_ACTION": APIManager.accept(userId: userId)
case "DECLINE_ACTION": APIManager.decline(userId: userId)
// handle other actions
default: break
}
print("\n=================================\n")
}
}
- Disable swizzling for Firebase
Add the FirebaseAppDelegateProxyEnabled key in the app’s Info.plist and set it to NO (boolean).
The SDK declares Firebase as an optional dependency, so you must add it to your app's build.gradle:
dependencies {
implementation platform('com.google.firebase:firebase-bom:33.8.0')
implementation 'com.google.firebase:firebase-messaging-ktx'
}
You also need a google-services.json from the Firebase Console placed at app/google-services.json, and the Google Services plugin applied in your build files.
The SDK automatically registers DashXFirebaseMessagingService via manifest merger — no manual manifest changes are needed. It handles rendering notifications and tracking delivered, opened, and dismissed events.
On Android 13+, you must request the runtime notification permission (POST_NOTIFICATIONS) before notifications can be shown. See Device Management for a full example.
Steps for iOS
-
Add your iOS app on Firebase Console:
Project Overview > Add App > iOS -
Download
GoogleService-Info.plist -
Add
GoogleService-Info.plist(Add Files…, Copy items if needed). Select the file → File Inspector → Target Membership → check your main app target only (see the iOS tab above). -
In your
Podfileadd the DashX iOS SDK and Firebase Messaging:
pod ‘DashX’, :git => ‘https://github.com/dashxhq/dashx-ios.git’, :tag => ‘1.1.9’
pod ‘FirebaseMessaging’, :modular_headers => true
- Install pods:
cd ios && pod install
- Implement
DashXRCTAppDelegatein yourAppDelegate:
import DashXReactNative
@main
class AppDelegate: DashXRCTAppDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL? {
bundleURL()
}
override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
override func notificationClicked(message: [AnyHashable: Any], actionIdentifier: String) {
// Handle notification tap
}
override func notificationDeliveredInForeground(message: [AnyHashable: Any]) -> UNNotificationPresentationOptions {
return [.banner, .sound]
}
override func handleLink(url: URL) {
// Handle deep link / universal link
}
}
DashXRCTAppDelegate automatically handles Firebase configuration, token management, and notification rendering. You can customise behaviour by overriding notificationDeliveredInForeground, notificationClicked, and handleLink.
Steps for Android
DashX requires Google Services installed in your app for Firebase to work:
- Add
google-servicesplugin in your/android/build.gradle
buildscript {
dependencies {
// ... other dependencies
classpath 'com.google.gms:google-services:4.4.2'
}
}
- Add this line in your
/android/app/build.gradle
apply plugin: 'com.google.gms.google-services'
-
Add your Android app on Firebase Console:
Project Overview > Add App > Android -
Download
google-services.jsonfrom there. -
Add
google-services.jsonat the following location:/android/app/google-services.json