flutter_voip_push_notification icon indicating copy to clipboard operation
flutter_voip_push_notification copied to clipboard

Receive notifications on Background and when app is killed

Open xellDart opened this issue 5 years ago • 11 comments

Hi, please help em, all is working on foreground, but when app is on Background method onResume method kill app, another question, I need show notification alert when app is killed, how I can do this?

xellDart avatar Feb 09 '20 23:02 xellDart

This plugin does not work for normal notifications. When using PushKit apps must report a system call otherwise iOS will kill your app after a while.

VictorUvarov avatar Mar 22 '20 04:03 VictorUvarov

i has same issues

vuitv avatar May 05 '20 08:05 vuitv

This plugin does not work for normal notifications. When using PushKit apps must report a system call otherwise iOS will kill your app after a while.

How to test app with VoIP push . I want move further only if it is working . Is there any website or something to test this. ..?

savadmv avatar May 28 '20 09:05 savadmv

This plugin does not work for normal notifications. When using PushKit apps must report a system call otherwise iOS will kill your app after a while.

I want to show notification like uber driver notification. What I need to do in this case. Please give enlighten me with some details

ziasultan2 avatar Jun 06 '20 12:06 ziasultan2

I had same issue and solved it

import UIKit
import PushKit
import flutter_voip_push_notification
import flutter_call_kit
import CallKit

import Flutter


@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate ,PKPushRegistryDelegate{
    
    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
             NSLog("didUpdatePushCredentials: \(pushCredentials.token)")
             // Process the received push
             FlutterVoipPushNotificationPlugin.didUpdate(pushCredentials, forType: type.rawValue);
         }
         
         func pushRegistry(_ registry: PKPushRegistry,
                           didReceiveIncomingPushWith payload: PKPushPayload,
                           for type: PKPushType,
                           completion: @escaping () -> Void) {
             let uuid = NSUUID().uuidString
             let handle = "+819011111111"
             let callerName = "Robert"

             FlutterCallKitPlugin.reportNewIncomingCall(uuid, handle: handle, handleType: "generic", hasVideo: false, localizedCallerName: callerName, fromPushKit: true)
             // Process the received push
             FlutterVoipPushNotificationPlugin.didReceiveIncomingPush(with: payload, forType: type.rawValue)

             completion()
         }
    
}

Add this code in your AppDelegate.swift Send Voip Notification from server . If your backend works in Nod Js , fine solution here

savadmv avatar Jun 09 '20 07:06 savadmv

Thank you for your solution. Is there any way I can pass caller name send from voip push notification to show on callkit

I had same issue and solved it

import UIKit
import PushKit
import flutter_voip_push_notification
import flutter_call_kit
import CallKit

import Flutter


@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate ,PKPushRegistryDelegate{
    
    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
             NSLog("didUpdatePushCredentials: \(pushCredentials.token)")
             // Process the received push
             FlutterVoipPushNotificationPlugin.didUpdate(pushCredentials, forType: type.rawValue);
         }
         
         func pushRegistry(_ registry: PKPushRegistry,
                           didReceiveIncomingPushWith payload: PKPushPayload,
                           for type: PKPushType,
                           completion: @escaping () -> Void) {
             let uuid = NSUUID().uuidString
             let handle = "+819011111111"
             let callerName = "Robert"

             FlutterCallKitPlugin.reportNewIncomingCall(uuid, handle: handle, handleType: "generic", hasVideo: false, localizedCallerName: callerName, fromPushKit: true)
             // Process the received push
             FlutterVoipPushNotificationPlugin.didReceiveIncomingPush(with: payload, forType: type.rawValue)

             completion()
         }
    
}

Add this code in your AppDelegate.swift Send Voip Notification from server . If your backend works in Nod Js , fine solution here

ziasultan2 avatar Jun 09 '20 12:06 ziasultan2

I don’t think you can that with this library . But it my be possible my modifying it. My requirement was to show a fixed Name . so i didn’t try for that .

savadmv avatar Jun 09 '20 13:06 savadmv

Thank you dear for your reply

ziasultan2 avatar Jun 09 '20 13:06 ziasultan2

@ziasultan2 Yes you can get all the info from the payload that you sent over from your server

Overview

  • when you recieve a voip notification parse the notification
  • if the notification is good, tell callkit to start the call
  • you can fill in the call details from the payload you get from the server

Objective-C

NSString *localizedName = payload[@"identifier"];

Swift

guard let localizedName = payload["identifier"] as? String else { return }

I would look at VoxImplants CallKit README for more details

VictorUvarov avatar Jul 12 '20 18:07 VictorUvarov

I had same issue and solved it

import UIKit
import PushKit
import flutter_voip_push_notification
import flutter_call_kit
import CallKit

import Flutter


@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate ,PKPushRegistryDelegate{
    
    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
             NSLog("didUpdatePushCredentials: \(pushCredentials.token)")
             // Process the received push
             FlutterVoipPushNotificationPlugin.didUpdate(pushCredentials, forType: type.rawValue);
         }
         
         func pushRegistry(_ registry: PKPushRegistry,
                           didReceiveIncomingPushWith payload: PKPushPayload,
                           for type: PKPushType,
                           completion: @escaping () -> Void) {
             let uuid = NSUUID().uuidString
             let handle = "+819011111111"
             let callerName = "Robert"

             FlutterCallKitPlugin.reportNewIncomingCall(uuid, handle: handle, handleType: "generic", hasVideo: false, localizedCallerName: callerName, fromPushKit: true)
             // Process the received push
             FlutterVoipPushNotificationPlugin.didReceiveIncomingPush(with: payload, forType: type.rawValue)

             completion()
         }
    
}

Add this code in your AppDelegate.swift Send Voip Notification from server . If your backend works in Nod Js , fine solution here

The application not crashing for me but no notification receiving in the background.But,It works in foreground.

Suhailakl avatar Nov 17 '21 09:11 Suhailakl

here App crashed with error message below reason: '-[CXProviderConfiguration initWithLocalizedName:]: parameter 'localizedName' cannot be nil'

evicoach avatar Dec 16 '21 09:12 evicoach