hiennguyen92 / flutter_callkit_incoming

Flutter Callkit Incoming
https://pub.dev/packages/flutter_callkit_incoming
MIT License
180 stars 312 forks source link

iOS Release Mode - difference in execution from Debug Mode (Background, Foreground, Lock screen) #575

Open AuriDeimantasDev opened 3 months ago

AuriDeimantasDev commented 3 months ago

Hello,

I'm little confused over different execution in debug and release modes.

In debug - it works really well. Background, foreground and locked screen. However once app is ran in release mode - only foreground works. When app is in background or locked screen - callkit will work only once brought up in the foreground.

DEMO below demonstrates callkit behaviour. 5s after button is clicked, callkit will execute.

![Debug Mode]

![ReleaseMode]

Is this expected?

Minimal sample code below.

// Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>Callkit Release Mode Issue</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>callkit_release_mode_issue</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>voip</string>
        <string>remote-notification</string>
        <string>processing</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
</dict>
</plist>

// main.dart

import 'package:flutter/material.dart';
import 'package:flutter_callkit_incoming/entities/entities.dart';
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
import 'package:uuid/uuid.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            InkWell(
              child: const Padding(
                padding: EdgeInsets.all(8.0),
                child: Text('Click to start Callkit in 5s'),
              ),
              onTap: () {
                Future.delayed(const Duration(seconds: 5)).then((_) {
                  final uuid = const Uuid().v4();
                  final callKitParams = CallKitParams(
                    id: uuid,
                    //TODO
                    nameCaller: 'todo caller name',
                    type: 1,
                    missedCallNotification: null,
                    duration: 60000,
                    android: null,
                    ios: const IOSParams(
                      handleType: 'generic',
                      supportsVideo: false,
                      supportsDTMF: false,
                      supportsHolding: false,
                      supportsGrouping: false,
                      supportsUngrouping: false,
                      // ringtonePath: 'system_ringtone_default',
                      ringtonePath: null,
                    ),
                  );
                  FlutterCallkitIncoming.showCallkitIncoming(callKitParams);
                });
              },
            )
          ],
        ),
      ),
    );
  }
}
leonardogbr commented 2 months ago

I'm having the same issue. Any suggestions?

mpamaro commented 2 months ago

Hey @AuriDeimantasDev, I've been running into this exact same issue for two weeks now. Have you fixed it?

pasaninsharp commented 1 month ago

Did someone find a fix for this?

Essenbay commented 1 month ago

How do you send VOIP notifications? PushKit provides SandBox (debug) and Production notifications, maybe you are sending wrong one? Device Token also maybe different from sandbox and production

himanshudeveloper commented 1 month ago

i am also facing same issue