Push Notifications

Guide to Comparing In-House and Third-Party Push Notification System for Developers and Startups

Anjali Arya
April 7, 2024
Learn the benefits of third-party push notification platforms for startups: faster dev cycles, reduced costs, and easy integration. Compare in-house vs third-party approaches.
TABLE OF CONTENTS

Startups face multiple challenges in attracting and retaining users. Effectively engaging users throughout their journey is crucial for success. Utilizing push notifications helps drive user interaction, improves retention, and promotes growth. Nevertheless, constructing an in-house push notification system consumes precious resources, requiring engineering talent and infrastructure investments.

This article explores third-party push notification platforms as a viable solution for startups eager to capitalize on push notifications' benefits while avoiding unnecessary expenditures. We shall delve into the following sections:

  1. Technical components of push notifications
  2. Technical Limitations of In-House Built Push Notification Systems
  3. Benefits of employing third-party push notification platforms

Section 1: Technical Components of Push Notifications

Let us briefly review the primary elements involved in setting up push notifications:

Device registration:

Clients register for push notifications by generating a token linked to their respective platforms (Android, iOS, Web). Code examples below demonstrate token generation:

  • Swift (iOS)
 
    import UserNotifications
    
    UNUserNotificationCenter.current().getNotificationSettings { settings in
      guard settings.authorizationStatus == .authorized else { return }
      
      UNUserNotificationCenter.current()
          .requestAuthorization(options:[.alert, .sound]) { granted, error in
              print("Permission granted: \(granted)")
              guard granted else { return }
              
              DispatchQueue.main.async {
                  UIApplication.shared.registerForRemoteNotifications()
              }
          }
    }
    
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
      let token = deviceToken.map { String(format: "%02x", $0) }.joined()
      print("Device Token: \(token)")
    }            
        
    
  • Javascript (Web)
 
    function urlB64ToUint8Array(base64String) {
      const padding = '='.repeat((4 - base64String.length % 4) % 4);
      const base64 = (base64String + padding)
        .replace(/-/g, '+')
        .replace(/_/g, '/');

      const rawData = window.atob(base64);
      const outputArray = new Uint8Array(rawData.length);

      for (let i = 0; i < rawData.length; ++i) {
        outputArray[i] = rawData.charCodeAt(i);
      }
      return outputArray;
    }

    if ('serviceWorker' in navigator && 'PushManager' in window) {
      // Register SW
      navigator.serviceWorker.register('/service-worker.js').then(registration => {
        // Register push
        registration.pushManager.subscribe({
          userVisibleOnly: true,
          applicationServerKey: urlB64ToUint8Array('your-public-vapid-key'),
        }).then(subscription => {
          // Send subscription object to the server
          fetch('/api/save-subscription', {
            method: 'POST',
            body: JSON.stringify(subscription),
            headers: { 'Content-Type': 'application/json' },
          });
        });
      });
    }      
        
    

Application server:

Servers communicate with APNs (Apple), FCM (Google), and WNS (Microsoft) to transmit notifications. Sample code in Python:

 
    import requests
    import json

    def send_notification(title, body, tokens):
      # Define request payload
      request_body = {
        'registration_ids': list(tokens),
        'notification': {
          'title': title,
          'body': body,
          ...
        },
        ...
      }

      # Make HTTP POST request
      url = 'https://fcm.googleapis.com/fcm/send'
      headers = {'Authorization': 'key=', 'Content-Type': 'application/json'}
      response = requests.post(url, data=json.dumps(request_body), headers=headers)

      # Check response status
      if response.status_code != 200:
        raise Exception('Failed to send notification')    
        
    

Section2: Technical Limitations of In-House Built Push Notification Systems

Fragmented Client Ecosystems

Each platform—iOS, Android, Web—has its unique characteristics and quirks when it comes to handling push notifications. For example, crafting a remote push notification payload for iOS devices requires specifying aps dictionary containing an alert field, sound file, or badge count. Meanwhile, configuring a similar payload structure for Android entails defining notification fields encapsulated within a data object.

 
    // iOS Payload Example
    {
        "aps": {
            "alert": {
                "title": "New Message",
                "body": "Hello, World!"
            },
            "sound": "default",
            "badge": 1
        }
    }

    // Android Payload Example
    {
        "to": "",
        "data": {
            "notification": {
                "title": "New Message",
                "body": "Hello, World!"
            }
        }
    } 
        
    

Moreover, setting up push notification services differs significantly among platforms. On Android, FCM (Firebase Cloud Messaging) registration tokens can change frequently, requiring diligent synchronization between the app and server components. Whereas, on iOS, registering for push notifications occurs locally within the app, resulting in the generation of a token managed centrally on the server side.

Transport Layers Complexity

Transport layer variety complicates matters further since separate services govern push notification distribution on each platform. Companies employing in-house push notification systems face the arduous challenge of juggling multiple transports, including APNs (Apple Push Notification service), FCM, and Web Push Protocol (for web browsers). Each transport exhibits distinct behaviors, error responses, and throttling patterns that developers must understand thoroughly.

Multi-Platform Payloads Construction

Crafting multi-platform push notification payloads introduces yet another level of intricacy. Although leveraging conditional statements facilitates constructing cohesive payloads, maintaining clean, concise code becomes cumbersome as the project scales.

 
    let payload;
    if (isWeb) {
        // Generate Web Push payload
    } else if (isAndroid) {
        // Generate FCM payload
    } else if (isiOS) {
        // Generate APNS payload
    }
        
    

Section 3: Benefits of Utilizing a Third-Party Push Notification System

Consolidated Client Coverage

A prime advantage of third-party push notification systems centers around consolidated client support. Rather than wrestling with platform-specific eccentricities individually, developers enjoy a standardized interface for crafting and dispatching push notifications.

 
    const payload = { /* ... */ };
    await whiteLabelService.send(payload);
        
    

This simplicity translates into expedited development cycles and decreased technical debt.

Single Point of Contact for Varied Transports

Additionally, third-party push notification systems act as a singular point of contact for managing multiple transport layers. No longer does a development team grapple with discrete services for push notification dissemination. Instead, a well-engineered library handles the necessary translation, interaction, and fallback strategies required for each supported transport type.

 
    # Sample Config File
    transports:
      - name: 'APNs'
        endpoint: ''
      - name: 'FCM'
        endpoint: ''
      - name: 'Web Push'
        endpoint: ''
        
    

Centralized Payloads Generation

Furthermore, third-party push notification systems centralize payload construction, easing expansion and refinement of push notification features. Imagine injecting an emoji reaction mechanism into your app's push notifications without needing to modify countless lines of code scattered throughout your repository.

 
    // Updated Payload Structure
    {
        "notification": {
            "title": "🚀 SuprSend push notifications!",
            "body": "🎉 Exciting news awaits you aboard our latest launch.",
            "actions": [{ "action": "view_launch", "title": "View Now" }],
            "emoji": ["🚀", "🎉"]
        }
    }
        
    

These improvements culminate in swifter iterations, simpler debugging procedures, and a stronger foundation for future modifications.

Frequently Asked Questions

1. What is a third-party push notification platform?

A third-party push notification platform is a service provided by external SAAS companies that allows developers to incorporate push notifications into their applications using customizable brand elements.

2. Why should startups invest in third-party push notification platforms early?

Startups investing early in third-party push notification platforms can benefit from quicker development speeds, reduced engineering hour allocation, and easier integration of push notification services.

3. How do third-party push notification platforms differ from building notifications in-house?

Building notifications in-house grants developers complete control over the notification service, while third-party platforms like SuprSend offer a pre-built service that can be easily integrated and customized according to brand requirements.

4. Who can benefit most from third-party push notifications?

Applications with varied uses for push notifications in their user engagement and retention strategies can greatly benefit from third-party push notification platforms, such as collaborative, eCommerce, and delivery applications.

5. What are the primary benefits of third-party push notification platforms?

Key benefits include business customization, increased development speed, and notification analytics, giving marketers the ability to analyze and gauge the effectiveness of notifications sent.

6. How do I choose the best third-party push notification platform for my product?

Determine your product's needs regarding notifications, and look for a platform that aligns with those needs, considering factors such as geographical reach, notification channels, user control, value-added features, and management dashboards.

7. Is there a difference between web and mobile push notifications?

Yes, web push notifications appear in users' browsers, while mobile push notifications display on users' mobile devices, though connected to, the respective application.

8. Are third-party push notification tools considered Software as a Service (SaaS)?

Yes, third-party push notification platforms are indeed categorized as SaaS because they are hosted online and accessed via an internet connection rather than installed on a computer.

9. Does SuprSend provide third-party push notification services?

Absolutely, SuprSend specializes in third-party push notification services aimed at helping developers efficiently implement push notifications in their applications.

Written by:
Anjali Arya
Product & Analytics, SuprSend
Get a powerful notification engine with SuprSend
Build smart notifications across channels in minutes with a single API and frontend components
Implement a powerful stack for your notifications
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.