Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev0.0.3

flutter_voip_push_notification

Notificação por Push VoIP do Flutter - Atualmente apenas iOS >= 8.0

Downloads em 30 dias
47
Curtidas
19
Pontos Pub
40

Instalar pacote

flutter pub add flutter_voip_push_notification

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

Um plugin Flutter para lidar com notificações push de VoIP, atualmente compatível com iOS 8.0 e versões posteriores. Permite que aplicativos de comunicação em tempo real recebam notificações push mesmo quando o app está encerrado, garantindo conectividade confiável para chamadas. O pacote integra-se ao serviço de notificações push da Apple (APNs) para entregar notificações silenciosas de VoIP, permitindo a ativação do app em segundo plano para chamadas entrantes. Projetado especificamente para aplicações de voz sobre IP, como chamadas VoIP ou plataformas de mensagens que exigem entrega imediata de notificações. Funciona perfeitamente dentro do ecossistema Flutter com configuração mínima. Sem suporte para Android neste momento.

Casos de uso

  • Aplicativos de chamada VoIP em tempo real
  • Notificações de chamada em segundo plano
  • Tratamento de notificação push silenciosa
  • Acordar o aplicativo em chamadas recebidas
  • Plataformas de comunicação por voz

Principais recursos

  • Suporte a push VoIP exclusivo para iOS
  • Entrega silenciosa de notificações
  • Ativação de aplicativo em segundo plano
  • Integração do Apple APNs
  • Configuração mínima necessária

Indicado para

  • desenvolvedores de aplicativos VoIP
  • Aplicativos de comunicação em tempo real
  • Projetos Flutter voltados para iOS
  • sistemas de roteamento de chamadas
  • Aplicativos que precisam de notificações em segundo plano confiáveis

Considerações

  • Sem suporte ao Android
  • Requer iOS 8.0 ou superior
  • É necessário configurar o certificado APNs
  • Limitado a casos de uso de VoIP
  • Dependente da infraestrutura de push da Apple

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

Flutter VoIP Push Notification

pub package Flutter VoIP Push Notification - Currently iOS >= 8.0 only

Motivation

Since iOS 8.0 there is an execellent feature called VoIP Push Notification (PushKit), while firebase_messaging does not support voip push notification which is only available on iOS >= 8.0 which is the reason for this plugin.

To understand the benefits of Voip Push Notification, please see VoIP Best Practices.

Note 1: This plugin works for only iOS. You can use firebase_messaging for Android by sending high priority push notification

Note 2 This This plugin was inspired by react-native-voip-push-notification and firebase_messaging

iOS

The iOS version should be >= 8.0 since we are using PushKit.

Enable VoIP Push Notification and Get VoIP Certificate

Please refer to VoIP Best Practices.

Note: Do NOT follow the Configure VoIP Push Notification part from the above link, use the instruction below instead.

AppDelegate.swift

...

import PushKit                     /* <------ add this line */
import flutter_voip_push_notification      /* <------ add this line */
...

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, PKPushRegistryDelegate {

    ...

    /* Add PushKit delegate method */

    // Handle updated push credentials
    func pushRegistry(_ registry: PKPushRegistry,
                      didReceiveIncomingPushWith payload: PKPushPayload,
                      for type: PKPushType,
                      completion: @escaping () -> Void){
        // Register VoIP push token (a property of PKPushCredentials) with server
        FlutterVoipPushNotificationPlugin.didReceiveIncomingPush(with: payload, forType: type.rawValue)
    }

    // Handle incoming pushes
    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
        // Process the received push
        FlutterVoipPushNotificationPlugin.didUpdate(pushCredentials, forType: type.rawValue);
    }

    ...
}
AppDelegate.m Modification

...

#import <PushKit/PushKit.h>                    /* <------ add this line */
#import "FlutterVoipPushNotificationPlugin.h"      /* <------ add this line */

...

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

...

/* Add PushKit delegate method */

// Handle updated push credentials
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
  // Register VoIP push token (a property of PKPushCredentials) with server
  [FlutterVoipPushNotificationPlugin didUpdatePushCredentials:credentials forType:(NSString *)type];
}

// Handle incoming pushes
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
  // Process the received push
  [FlutterVoipPushNotificationPlugin didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
}

...

@end

Usage

Add flutter_voip_push_notification as a dependency in your pubspec.yaml file.

Example

import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_voip_push_notification/flutter_voip_push_notification.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _pushToken = '';
  FlutterVoipPushNotification _voipPush = FlutterVoipPushNotification();
  @override
  void initState() {
    super.initState();
    configure();
  }

  // Configures a voip push notification
  Future<void> configure() async {
    // request permission (required)
    await _voipPush.requestNotificationPermissions();

    // listen to voip device token changes
    _voipPush.onTokenRefresh.listen(onToken);

    // do configure voip push
    _voipPush.configure(onMessage: onMessage, onResume: onResume);
  }

  /// Called when the device token changes
  void onToken(String token) {
    // send token to your apn provider server
    setState(() {
      _pushToken = token;
    });
  }

  /// Called to receive notification when app is in foreground
  ///
  /// [isLocal] is true if its a local notification or false otherwise (remote notification)
  /// [payload] the notification payload to be processed. use this to present a local notification
  Future<dynamic> onMessage(bool isLocal, Map<String, dynamic> payload) {
    // handle foreground notification
    print("received on foreground payload: $payload, isLocal=$isLocal");
    return null;
  }

  /// Called to receive notification when app is resuming from background
  ///
  /// [isLocal] is true if its a local notification or false otherwise (remote notification)
  /// [payload] the notification payload to be processed. use this to present a local notification
  Future<dynamic> onResume(bool isLocal, Map<String, dynamic> payload) {
    // handle background notification
    print("received on background payload: $payload, isLocal=$isLocal");
    showLocalNotification(payload);
    return null;
  }

  showLocalNotification(Map<String, dynamic> notification) {
    String alert = notification["aps"]["alert"];
    _voipPush.presentLocalNotification(LocalNotification(
      alertBody: "Hello $alert",
    ));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Received Voip Push token: $_pushToken\n'),
        ),
      ),
    );
  }
}

Categorias

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.