Skip to main content

feeddo_push_notification_apns 0.1.1 copy "feeddo_push_notification_apns: ^0.1.1" to clipboard
feeddo_push_notification_apns: ^0.1.1 copied to clipboard

Direct Apple Push Notification service (APNs) bridge for Flutter on iOS. Lightweight APNs token management, foreground presentation, and tap handling without Firebase.

feeddo_push_notification_apns #

pub package

A lightweight, zero-boilerplate Apple Push Notification service (APNs) bridge for Flutter iOS applications.

Designed specifically for apps using Feeddo or any iOS-only Flutter app that needs direct APNs push notifications without requiring Firebase or FCM.


โœจ Why feeddo_push_notification_apns? #

  • ๐Ÿšซ No Firebase / FCM Required: Communicates directly with Apple APNs.
  • โšก Zero Swift Boilerplate in AppDelegate: Automatically registers as a Flutter application delegate and UNUserNotificationCenterDelegateโ€”no manual MethodChannel setup or 200 lines of Swift in your project!
  • ๐Ÿ”‘ Automatic Token Generation: Translates native binary device tokens to clean hex strings ready for APNs HTTP/2 servers.
  • ๐Ÿ“ฑ Cold-Start & Background Tap Handling: Reliably delivers initial notifications when launched from terminated or background states.
  • ๐Ÿ”” Foreground Banners: Automatically displays banners, sounds, and badges when notifications arrive while the app is active, and notifies Flutter via streams.
  • ๐Ÿค First-Class Feeddo Integration: Provides attachToFeeddo to seamlessly wire push token sync and notification routing to feeddo_flutter.

๐Ÿš€ Getting Started #

1. Add to pubspec.yaml #

flutter pub add feeddo_push_notification_apns

2. Configure iOS Capabilities #

In Xcode:

  1. Open your ios/Runner.xcworkspace.
  2. Select the Runner target โ†’ Signing & Capabilities โ†’ + Capability โ†’ Add Push Notifications.
  3. Under Background Modes (if desired), check Remote notifications.

(Or ensure Runner.entitlements contains the aps-environment key:)

<dict>
  <key>aps-environment</key>
  <string>development</string>
</dict>

Note: Debug builds and the iOS Simulator use development. Release and TestFlight builds are automatically signed with production by Xcode.


๐Ÿ›  Usage with Feeddo #

import 'package:flutter/material.dart';
import 'package:feeddo_flutter/feeddo_flutter.dart';
import 'package:feeddo_push_notification_apns/feeddo_push_notification_apns.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // 1. Initialize APNs Bridge (registers delegates and retrieves initial launch tokens)
  await FeeddoPushNotificationApns.instance.initialize();

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  FeeddoApnsSubscription? _apnsSub;

  @override
  void initState() {
    super.initState();
    _initFeeddo();
  }

  Future<void> _initFeeddo() async {
    // Initialize Feeddo SDK
    await Feeddo.init(
      apiKey: 'YOUR_FEEDDO_API_KEY',
      context: context,
      externalUserId: 'user_123',
      pushToken: FeeddoPushNotificationApns.instance.token,
      pushProvider: FeeddoPushProvider.apns,
      isInAppNotificationOn: true,
    );

    // Wire live APNs token updates and notification taps
    _apnsSub = FeeddoPushNotificationApns.instance.attachToFeeddo(
      onToken: (token) => Feeddo.registerPushToken(
        pushToken: token,
        pushProvider: FeeddoPushProvider.apns,
      ),
      onNotificationTap: (payload) => Feeddo.handleNotificationTap(
        context,
        payload,
      ),
    );
  }

  @override
  void dispose() {
    _apnsSub?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(body: Center(child: Text('Hello Feeddo'))),
    );
  }
}

๐Ÿ”” Requesting Notification Permissions in an Appropriate Place #

Do not prompt for notification permissions directly in main() on cold startup. In line with Apple's Human Interface Guidelines, prompt the user in a contextual, appropriate place so they understand why notifications are valuable:

  • During Onboarding: On a dedicated permissions or benefits walkthrough screen.
  • In Settings / Notifications: With a toggle that user controls.
  • In the Feedback / Support Flow: Right when the user taps to open Support Chat or submits a bug report/feature request, so they are alerted when a reply arrives:
// Place this inside Settings, Onboarding, or when the user opens Support:
final granted = await FeeddoPushNotificationApns.instance.requestNotificationPermissions(
  alert: true,
  badge: true,
  sound: true,
);

if (granted) {
  debugPrint('Notification permissions granted by user.');
}

๐Ÿ’ก Standalone APNs Usage (Without Feeddo) #

You can also use this library as a general-purpose APNs bridge:

final apns = FeeddoPushNotificationApns.instance;

// Initialize
final result = await apns.initialize();
print('Cached token: ${result.token}');

// Request permission when appropriate in your app flow:
final granted = await apns.requestNotificationPermissions();

// Check detailed notification settings
final settings = await apns.getNotificationSettings();
print('Authorized: ${settings.isAuthorized}, Sound: ${settings.soundEnabled}');

// Listen for device token
apns.onToken.listen((hexToken) {
  print('New APNs device token: $hexToken');
});

// Listen for user tapping a notification
apns.onNotificationOpened.listen((Map<String, dynamic> payload) {
  print('Notification tapped: $payload');
});

// Listen for foreground notifications
apns.onForegroundNotification.listen((Map<String, dynamic> payload) {
  print('Foreground notification: $payload');
});

// Check if app was cold-launched by tapping a push notification
final initialPayload = await apns.getInitialNotification();
if (initialPayload != null) {
  print('Cold launch payload: $initialPayload');
}

๐Ÿงช Testing on iOS Simulator #

To test push notifications on an Apple Silicon Mac using the iOS Simulator:

  1. Ensure your Apple ID is signed in under Settings โ†’ Apple ID in the simulator.
  2. If the simulator does not deliver push notifications, kickstart the push daemon on your Mac:
    launchctl kickstart -k system/com.apple.apsd
    

๐Ÿ“„ License #

MIT License. See LICENSE for details.

0
likes
0
points
166
downloads

Publisher

unverified uploader

Weekly Downloads

Direct Apple Push Notification service (APNs) bridge for Flutter on iOS. Lightweight APNs token management, foreground presentation, and tap handling without Firebase.

Homepage
Repository (GitHub)
View/report issues

Topics

#push-notifications #apns #ios #notifications #feeddo

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on feeddo_push_notification_apns

Packages that implement feeddo_push_notification_apns