logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

ZPNs upgrade guide


This article introduces some instructions and precautions for upgrading the ZPNs Flutter framework SDK version.

2.6.0 Upgrade Guide

ZPNs 2.6.0 separates CallKit into a separate plugin. If your project uses an older version of ZPNs, you need to integrate the zego_callkit plugin separately to achieve compatibility after the upgrade.

  1. Import the zego_callkit plugin

    Open the "pubspec.yaml" file and add the "zego_callkit" dependency in "pub" format:

    Untitled
    dependencies:
        # Please fill in the specific SDK version number
        # Please query the latest version of the SDK from xxx and modify x.y.z to the specific version number
        zego_callkit: ^x.y.z
    
    1
    Copied!
  2. Use the new header file to achieve compatibility after the upgrade.

    Untitled
    import 'package:zego_callkit/zego_callkit.dart';
    
    1
    Copied!

2.5.0 Upgrade Guide

Changes in data class member variable types

The type of "extras" in ZPNsMessage has been changed from Map<String, Object> to Map<String, Object?>to support the case where the value of the Map may be null when converting Json to map. If you are using ZPNs version 2.5.0 or below and need to use extras, please note that the value type of this field Map has been changed.

ZPNsMessage

New Type
Old Type
  class ZPNsMessage {
      String title = "";
      String content = "";
      Map<String, Object?> extras = {}; // The value of extras "Object?" supports null
      ZPNsPushSourceType pushSourceType;
      ZPNsMessage({required this.pushSourceType});
  }
1
Copied!
  class ZPNsMessage {
      String title = "";
      String content = "";
      Map<String, Object> extras = {}; // The value of extras "Object" does not support null
      ZPNsPushSourceType pushSourceType;
      ZPNsMessage({required this.pushSourceType});
  }
1
Copied!

2.2.0 Upgrade Guide

Interface changes

enableDebug

The enableDebug interface is no longer used for the iOS platform.

setPushConfig

New Interface
Old Interface
  static setPushConfig(ZPNsConfig config)
1
Copied!
  static Future<void> setPushConfig(ZPNsConfig config)
1
Copied!

registerPush

When using registerPush on the iOS side, ZPNsIOSEnvironment needs to be filled in advance based on whether the certificate selected during packaging is development or production.

New Interface
Old Interface
  Future<void> registerPush({ZPNsIOSEnvironment iOSEnvironment});
1
Copied!
  static Future<void> registerPush();
1
Copied!

applyNotificationPermission

New Interface
Old Interface
  Future<void> applyNotificationPermission();
1
Copied!
  static Future<void> applyNotificationPermission();
1
Copied!

Changes in payload acquisition method

  • Old method:

    Get it from the payload in ZPNsMessage.

  • New method:

Untitled
ZPNsEventHandler.onNotificationClicked = (ZPNsMessage zpnsMessage) {
    if (zpnsMessage.pushSourceType == ZPNsPushSourceType.APNs) {
        Map aps = Map.from(zpnsMessage.extras['aps'] as Map);
        String payload = aps['payload'];
        log("My payload is $payload");
    } else if (zpnsMessage.pushSourceType == ZPNsPushSourceType.FCM) {
        // This interface is not supported by FCM. Please use Intent in Android Activity to get the payload field.
    }
    log("user clicked the offline push notification,title is ${zpnsMessage.title},content is ${zpnsMessage.content}");
  };
1
Copied!

Previous

ZIM upgrade guide

Next

Authentication