peerwaya / flutter_voip_push_notification

Flutter VoIP Push Notification - Currently iOS >= 8.0 only
BSD 2-Clause "Simplified" License
28 stars 33 forks source link

Receive notifications on Background and when app is killed #2

Open xellDart opened 4 years ago

xellDart commented 4 years ago

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?

VictorUvarov commented 4 years ago

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.

vuitv commented 4 years ago

i has same issues

savadmv commented 4 years ago

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. ..?

ziasultan2 commented 4 years ago

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

savadmv commented 4 years ago

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 commented 4 years ago

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

savadmv commented 4 years ago

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 .

ziasultan2 commented 4 years ago

Thank you dear for your reply

VictorUvarov commented 4 years ago

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

Overview

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

Suhailakl commented 3 years ago

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.

evicoach commented 2 years ago

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