All Projects → peerwaya → flutter_voip_push_notification

peerwaya / flutter_voip_push_notification

Licence: BSD-2-Clause license
Flutter VoIP Push Notification - Currently iOS >= 8.0 only

Programming Languages

objective c
16641 projects - #2 most used programming language
dart
5743 projects
ruby
36898 projects - #4 most used programming language
swift
15916 projects
kotlin
9241 projects
HTML
75241 projects

Projects that are alternatives of or similar to flutter voip push notification

flutter ios voip kit
One-to-one video call using CallKit and PushKit with flutter iOS app.
Stars: ✭ 55 (+111.54%)
Mutual labels:  voip, pushkit, callkit
VoIPPush
viop推送实现呼叫连续响铃效果
Stars: ✭ 88 (+238.46%)
Mutual labels:  voip, pushkit
Mediadevices
Go implementation of the MediaDevices API.
Stars: ✭ 197 (+657.69%)
Mutual labels:  voip
sems-yeti
YETI application for SEMS core
Stars: ✭ 15 (-42.31%)
Mutual labels:  voip
anyfesto
Low cost Raspberry Pi /Linux based access point with audio, education and communications local content server. Inspired by the ideas of sharing with others. Anyfesto - a platform from which to speak.
Stars: ✭ 66 (+153.85%)
Mutual labels:  voip
Jackknife
⚔️ 金轮法王,哦不,是轮子大师带你玩转Android,是时候尝试下MVVM了。这是一个Android应用开发全家桶库,支持Kotlin+MVVM+Dagger2+Retrofit架构。
Stars: ✭ 215 (+726.92%)
Mutual labels:  voip
ominicontacto
The Open Source Contact Center Solution (mirror of https://gitlab.com/omnileads/ominicontacto)
Stars: ✭ 24 (-7.69%)
Mutual labels:  voip
Flutter Webrtc
WebRTC plugin for Flutter Mobile/Desktop/Web
Stars: ✭ 2,764 (+10530.77%)
Mutual labels:  voip
Oreka
Enterprise telephony recording and retrieval system with web based user interface.
Stars: ✭ 20 (-23.08%)
Mutual labels:  voip
tSIP
SIP softphone
Stars: ✭ 103 (+296.15%)
Mutual labels:  voip
freeswitch-esl-all
freeswitch event socket base on netty 4 and has some new features.
Stars: ✭ 110 (+323.08%)
Mutual labels:  voip
SilentServer
Silent is very lightweight, high quality - low latency voice chat for gaming. The server runs on Windows and Linux.
Stars: ✭ 52 (+100%)
Mutual labels:  voip
Siprtcproxy
网关服务:Sip与Rtc互通,实现Web,Android,iOS,小程序,SIP座机,PSTN电话,手机互通。
Stars: ✭ 217 (+734.62%)
Mutual labels:  voip
guildbit
🔉 Mumble Hosting Platform
Stars: ✭ 50 (+92.31%)
Mutual labels:  voip
Linphone Desktop
Linphone is a free VoIP and video softphone based on the SIP protocol. Mirror of git://git.linphone.org/linphone-desktop.git
Stars: ✭ 212 (+715.38%)
Mutual labels:  voip
connectycube-flutter-call-kit
A Flutter plugin for displaying call screen when the app in the background or terminated.
Stars: ✭ 35 (+34.62%)
Mutual labels:  callkit
Teamtalk5
TeamTalk 5 Development
Stars: ✭ 192 (+638.46%)
Mutual labels:  voip
Restcomm Connect
The Open Source Cloud Communications Platform
Stars: ✭ 232 (+792.31%)
Mutual labels:  voip
sipsorcery-media
The SIPSorcery library for WebRTC infrastructure and Windows audio and video capture.
Stars: ✭ 19 (-26.92%)
Mutual labels:  voip
switchy
async FreeSWITCH cluster control
Stars: ✭ 67 (+157.69%)
Mutual labels:  voip

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'),
        ),
      ),
    );
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].