handlePush static method

Future<CalloopPush?> handlePush(
  1. Map data, {
  2. NativeCallUi? ui,
  3. NativeCallStyle style = const NativeCallStyle(),
})

Handle a push: a Calloop call push shows or dismisses the native call screen and returns the parsed push; anything else returns null untouched.

Implementation

static Future<CalloopPush?> handlePush(
  Map<dynamic, dynamic> data, {
  NativeCallUi? ui,
  NativeCallStyle style = const NativeCallStyle(),
}) async {
  final push = CalloopPush.parse(data);
  if (push == null) return null;
  final native = ui ?? CallkitNativeUi();
  switch (push.type) {
    case CalloopPushType.incoming:
      await native.showIncoming(
        NativeIncoming(uuid: push.uuid, callId: push.callId, name: push.displayName, handle: push.customerAddress),
        style,
      );
    case CalloopPushType.cancelled:
      await native.end(push.uuid);
    case CalloopPushType.alert:
      break;   // iOS banner: the notification itself is the UI
  }
  return push;
}