LogoLogo
  • Home
  • Integration & SDKs
    • Web / Browser Push
      • Wordpress Integration Steps
      • Wix Integration Steps
      • Safari
        • Safari on Desktop
        • Safari on Mobile (iOS / iPadOS)
      • SDK
        • SDK Methods
        • SDK Events
        • Customizing Prompt CSS
        • AMP Support
        • E-Commerce / Abandoned Cart
    • Native App Push
      • Apple / iOS
        • P8 Key or P12 Cert Setup
        • SDK: Swift / Obj-C
          • Activity Tracking
          • Deep Linking
          • Live Activities
          • App Messages
          • Identity Synchronization
          • SDK Methods
          • SDK Delegates
        • SDK: React Native
        • SDK: Flutter
        • Advanced
          • Self-Managed Integration
        • iOS SDK Changelog
      • Android
        • Firebase App Setup
        • SDK: Kotlin / Java
          • Deep Linking
          • Activity Tracking
          • App Messages
          • Identity Synchronization
          • SDK Methods
          • SDK Callbacks
          • Live Activities
        • SDK: React Native
        • SDK: Flutter
        • Advanced
          • Self-Managed Integration
        • Android SDK Changelog
      • React Native
        • Android: Firebase App Setup
        • iOS: P8 Key or P12 Cert Setup
        • SDK: React Native
          • Deep Linking
          • Activity Tracking
          • Subscriber Matching
          • Live Activities
          • App Messages
          • SDK Methods
        • React Native SDK Changelog
      • Flutter
        • Android: Firebase App Setup
        • iOS: P8 Key or P12 Cert Setup
        • SDK: Flutter
          • Deep Linking
          • Activity Tracking
          • Subscriber Matching
          • Live Activities
          • App Messages
          • SDK Methods
  • API
    • API Access Management
    • API Reference
  • Platform
    • Dashboard
    • Notifications
      • A/B Testing
      • Custom Buttons
      • Notification Previews
      • Inline Segmentation
      • Notification Templates
      • Macros
      • Native App Push Notifications
    • App Messages
    • Segments
      • Custom Geo Segmentation
    • Campaigns
    • Insights
    • User Management
    • Organizations
      • Multi-Factor Authentication
      • Single Sign On
        • Google Workspace
        • Microsoft Azure AD
        • Okta Workforce
      • Multi-Domain Notifications
      • Multi-Domain Segments
      • API Access
    • Multi-Channel Notifications
  • Info Center
    • Launch Guide & Best Practices
      • Landing Domain Whitelist
    • Web / Browser Push
      • Common Questions
      • Browser Support
      • Retrieve Push User ID
      • Not Getting Prompted
      • Not Receiving Notifications
      • How to Unsubscribe
    • Native App Push
      • Retrieve Push User ID
    • Workflow Planning
Powered by GitBook
On this page
  • Integrating Your Own Messaging Service
  • Messaging Service Example
  1. Integration & SDKs
  2. Native App Push
  3. Android
  4. Advanced

Self-Managed Integration

To make integrations easier the PushSDK automatically includes an extension of the FirebaseMessagingService class. However, you may have your own service and need to forward calls to the PushSDK in several scenarios including:

  • Conflicts with other SDKs

  • Conflicting third party development solutions

  • Our messaging service conflicts with your existing architecture

We suggest that you only consider a self-managed integration if you need to customize the integration with FirebaseMessaging. If you choose to use a self-managed integration you will need to ensure that any new releases to the PushSDK do not add additional methods that must be called manually.

Integrating Your Own Messaging Service

First you will want to remove the service automatically added by the PushSDK and add your own to the app manifest file.

<manifest 
    ...
    xmlns:tools="http://schemas.android.com/tools"
>
    <!-- Remove the PushSDK messaging service -->
    <service
        android:name="com.pushly.android.PNMessagingService"
        tools:node="remove" />

    <!-- Add your own messaging service -->
    <service
        android:name=".MyMessageService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
</manifest>

Once you have added your own messaging service you'll also be required to place calls to the PushSDK to invoke the methods that are no longer automatically handled. If you do not implement all of the following methods the PushSDK may not function properly.

The methods you must call manually are:

  • PushSDK.handleOnNewToken(token: String)

  • PushSDK.handleOnMessageReceived(message: RemoteMessage)

Messaging Service Example

override fun onNewToken(token: String) {
    super.onNewToken(token)
    PushSDK.handleOnNewToken(token)
}

override fun onMessageReceived(message: RemoteMessage) {
    super.onMessageReceived(message)
    PushSDK.handleOnMessageReceived(message)
}
@Override
public void onNewToken(@NonNull String token) {
    super.onNewToken(token);
    PushSDK.handleOnNewToken(token);
}

@Override
public void onMessageReceived(@NonNull RemoteMessage message) {
    super.onMessageReceived(message);
    PushSDK.handleOnMessageReceived(message);
}
PreviousAdvancedNextAndroid SDK Changelog

Last updated 4 months ago