notification_incoming_call 0.0.1 copy "notification_incoming_call: ^0.0.1" to clipboard
notification_incoming_call: ^0.0.1 copied to clipboard

A new Flutter project.

notification_incoming_call #

A Flutter plugin to show incoming call notification in your Flutter app(Custom for Android/iOS).

⭐ Features #

  • Show an incoming call

  • Start an outgoing call


🚀  Installation #

  1. Install Packages
  • Run this command:
    flutter pub add notification_incoming_call
    
  • Add pubspec.yaml:
        dependencies:
          notification_incoming_call: any
    
  1. Configure Project
  • Android
    • AndroidManifest.xml
     <manifest...>
         ...
         <!-- 
             Using for load image from internet
         -->
         <uses-permission android:name="android.permission.INTERNET"/>
     </manifest>
    
  • iOS
    • Info.plist
    <key>UIBackgroundModes</key>
    <array>
        <string>processing</string>
        <string>remote-notification</string>
        <string>voip</string>
    </array>
    
  1. Usage
  • Import

    import 'package:notification_incoming_call/notification_incoming_call.dart';
    
  • Received an incoming call

      this._currentUuid = _uuid.v4();
      var params = <String, dynamic>{
        'id': _currentUuid,
        'nameCaller': 'Baron Nwobi',
        'appName': 'Callkit',
        'avatar': 'https://i.pravatar.cc/100',
        'handle': '0123456789',
        'type': 0,
        'duration': 30000,
        'extra': <String, dynamic>{'userId': '1a2b3c4d'},
        'headers': <String, dynamic>{'apiKey': 'Abc@123!', 'platform': 'flutter'},
        'android': <String, dynamic>{
          'isCustomNotification': true,
          'isShowLogo': false,
          'backgroundColor': '#0955fa',
          'backgroundUrl': 'https://i.pravatar.cc/500',
          'actionColor': '#4CAF50'
        },
        'ios': <String, dynamic>{
          'iconName': 'AppIcon40x40',
          'handleType': 'generic',
          'supportsVideo': true,
          'maximumCallGroups': 2,
          'maximumCallsPerCallGroup': 1,
          'audioSessionMode': 'default',
          'audioSessionActive': true,
          'audioSessionPreferredSampleRate': 44100.0,
          'audioSessionPreferredIOBufferDuration': 0.005,
          'supportsDTMF': true,
          'supportsHolding': true,
          'supportsGrouping': false,
          'supportsUngrouping': false,
          'ringtonePath': 'Ringtone.caf'
        }
      };
      await NotificationIncomingCall.showCallkitIncoming(params);
    
  • Started an outgoing call

      this._currentUuid = _uuid.v4();
      var params = <String, dynamic>{
        'id': this._currentUuid,
        'nameCaller': 'Baron Nwobi',
        'handle': '0123456789',
        'type': 1,
        'extra': <String, dynamic>{'userId': '1a2b3c4d'},
        'ios': <String, dynamic>{'handleType': 'generic'}
      };
      await NotificationIncomingCall.startCall(params);
    
  • Ended an incoming/outgoing call

      var params = <String, dynamic>{'id': this._currentUuid};
      await NotificationIncomingCall.endCall(params);
    
  • Ended all calls

      await NotificationIncomingCall.endAllCalls();
    
  • Get active calls. iOS: return active calls from Callkit, Android: only return last call

      await NotificationIncomingCall.activeCalls();
    

    Output

    [{"id": "8BAA2B26-47AD-42C1-9197-1D75F662DF78", ...}]
    
  • Listen events

      NotificationIncomingCall.onEvent.listen((event) {
        switch (event!.name) {
          case CallEvent.ACTION_CALL_INCOMING:
            // TODO: received an incoming call
            break;
          case CallEvent.ACTION_CALL_START:
            // TODO: started an outgoing call
            // TODO: show screen calling in Flutter
            break;
          case CallEvent.ACTION_CALL_ACCEPT:
            // TODO: accepted an incoming call
            // TODO: show screen calling in Flutter
            break;
          case CallEvent.ACTION_CALL_DECLINE:
            // TODO: declined an incoming call
            break;
          case CallEvent.ACTION_CALL_ENDED:
            // TODO: ended an incoming/outgoing call
            break;
          case CallEvent.ACTION_CALL_TIMEOUT:
            // TODO: missed an incoming call
            break;
          case CallEvent.ACTION_CALL_CALLBACK:
            // TODO: only Android - click action `Call back` from missed call notification
            break;
          case CallEvent.ACTION_CALL_TOGGLE_HOLD:
            // TODO: only iOS
            break;
          case CallEvent.ACTION_CALL_TOGGLE_MUTE:
            // TODO: only iOS
            break;
          case CallEvent.ACTION_CALL_TOGGLE_DMTF:
            // TODO: only iOS
            break;
          case CallEvent.ACTION_CALL_TOGGLE_GROUP:
            // TODO: only iOS
            break;
          case CallEvent.ACTION_CALL_TOGGLE_AUDIO_SESSION:
            // TODO: only iOS
            break;
        }
      });
    
  • Call from Native (iOS PushKit)

      var info = [String: Any?]()
      info["id"] = "44d915e1-5ff4-4bed-bf13-c423048ec97a"
      info["nameCaller"] = "Baron Nwobi"
      info["handle"] = "0123456789"
      SwiftNotificationIncomingCallPlugin.sharedInstance?.showCallkitIncoming(notification_incoming_call.Data(args: info), fromPushKit: true)
    
6
likes
130
pub points
50%
popularity

Publisher

unverified uploader

A new Flutter project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on notification_incoming_call