<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aswin Andro</title>
    <description>The latest articles on DEV Community by Aswin Andro (@aswinandro).</description>
    <link>https://dev.to/aswinandro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3789240%2F42819bda-7d9e-44a9-ad84-cdf73802cb1f.jpeg</url>
      <title>DEV Community: Aswin Andro</title>
      <link>https://dev.to/aswinandro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aswinandro"/>
    <language>en</language>
    <item>
      <title>How to Fix Expo Push Token Timeouts and 'EXNotificationsDelegate' Build Errors</title>
      <dc:creator>Aswin Andro</dc:creator>
      <pubDate>Tue, 24 Feb 2026 11:24:30 +0000</pubDate>
      <link>https://dev.to/aswinandro/how-to-fix-expo-push-token-timeouts-and-exnotificationsdelegate-build-errors-4iah</link>
      <guid>https://dev.to/aswinandro/how-to-fix-expo-push-token-timeouts-and-exnotificationsdelegate-build-errors-4iah</guid>
      <description>&lt;h1&gt;
  
  
  🚀 Solving Expo Push Notification Headaches
&lt;/h1&gt;

&lt;p&gt;If you are running a &lt;strong&gt;React Native&lt;/strong&gt; project using the &lt;strong&gt;Expo Bare Workflow (SDK 50+)&lt;/strong&gt;, you've likely hit a wall with iOS push notifications. You’ve set up your APNs &lt;code&gt;.p8&lt;/code&gt; key, but things still break.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔴 The Problems
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The JS Timeout:&lt;/strong&gt; &lt;code&gt;getExpoPushTokenAsync&lt;/code&gt; consistently throws &lt;code&gt;Token fetch timed out after 6000ms&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Xcode Error:&lt;/strong&gt; &lt;code&gt;error: cannot find 'EXNotificationsDelegate' in scope&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🛠 Phase 1: Fixing the JavaScript Race Condition
&lt;/h2&gt;

&lt;p&gt;On iOS, the first token generation is slow. If multiple components call &lt;code&gt;getExpoPushToken&lt;/code&gt; at the same time, the native bridge can hang. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Solution: A Global Fetch Lock
&lt;/h3&gt;

&lt;p&gt;We use a &lt;strong&gt;Singleton Promise&lt;/strong&gt; pattern. This ensures that even if 10 components call your token function at once, only &lt;strong&gt;one&lt;/strong&gt; actual request is sent to the native side.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
typescript
import * as Notifications from 'expo-notifications';

// 🔒 Global lock to prevent bridge congestion
let globalTokenFetchPromise: Promise&amp;lt;string | null&amp;gt; | null = null;

export async function getExpoPushToken() {
  if (globalTokenFetchPromise) {
    return await globalTokenFetchPromise;
  }

  globalTokenFetchPromise = (async () =&amp;gt; {
    try {
      // We wrap the Expo call in a race to control the timeout manually
      const token = await Promise.race([
        Notifications.getExpoPushTokenAsync({ 
          projectId: 'your-project-id' 
        }),
        new Promise((_, reject) =&amp;gt; 
          setTimeout(() =&amp;gt; reject(new Error('Push Token Timeout')), 10000)
        )
      ]) as Notifications.ExpoPushToken;

      return token.data;
    } catch (error) {
      console.error("❌ Push Token Error:", error);
      return null;
    }
  })();

  try {
    return await globalTokenFetchPromise;
  } finally {
    // Reset so the next call can try again if the first failed
    globalTokenFetchPromise = null;
  }
}

## 🛠 Phase 2: Solving the 'EXNotificationsDelegate' Build Error

In Expo SDK 50+, many developers encounter the error: `error: cannot find 'EXNotificationsDelegate' in scope`. This happens because `EXNotificationsDelegate` is an internal Objective-C class that is no longer exposed to Swift in the same way.

### The Modern Solution: Inherit from `ExpoAppDelegate`

Instead of manually trying to bridge Objective-C delegates, you should inherit your `AppDelegate` from `ExpoAppDelegate`. This class is part of the newer Expo Modules architecture and automatically handles the plumbing for APNs tokens and notification events.
---
import UIKit
import Expo
import ExpoModulesCore
import React
import React_RCTAppDelegate

@main
class AppDelegate: ExpoAppDelegate { 
  var window: UIWindow?

  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  ) -&amp;gt; Bool {

    let delegate = ReactNativeDelegate()
    let factory = RCTReactNativeFactory(delegate: delegate)
    self.reactNativeDelegate = delegate
    self.factory = factory 

    window = UIWindow(frame: UIScreen.main.bounds)

    // ⚠️ Replace "YourAppName" with the name in your app.json
    factory.startReactNative(withModuleName: "YourAppName", in: window, launchOptions: launchOptions)

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  override func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -&amp;gt; Bool {
    return super.application(application, open: url, options: options) || RCTLinkingManager.application(application, open: url, options: options)
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>ios</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
