Skip to content

Commit

Permalink
fix: iOS crash on forced unwrapping (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 committed Jun 27, 2023
1 parent 01534f5 commit f514174
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions ios/Classes/CustomerIOInAppMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CioMessagingInApp

public class CusomterIOInAppMessaging: NSObject, FlutterPlugin {

private var methodChannel: FlutterMethodChannel!
private var methodChannel: FlutterMethodChannel?

public static func register(with registrar: FlutterPluginRegistrar) {
}
Expand All @@ -13,12 +13,18 @@ public class CusomterIOInAppMessaging: NSObject, FlutterPlugin {
super.init()

methodChannel = FlutterMethodChannel(name: "customer_io_messaging_in_app", binaryMessenger: registrar.messenger())

guard let methodChannel = methodChannel else {
print("customer_io_messaging_in_app methodChannel is nil")
return
}

registrar.addMethodCallDelegate(self, channel: methodChannel)
}


deinit {
methodChannel.setMethodCallHandler(nil)
methodChannel?.setMethodCallHandler(nil)
}

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
Expand All @@ -32,7 +38,7 @@ public class CusomterIOInAppMessaging: NSObject, FlutterPlugin {
}

func detachFromEngine() {
methodChannel.setMethodCallHandler(nil)
methodChannel?.setMethodCallHandler(nil)
methodChannel = nil
}
}
2 changes: 1 addition & 1 deletion ios/customer_io.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'customer_io'
s.version = '1.2.1'
s.version = '1.2.2'
s.summary = 'Customer.io plugin for Flutter'
s.homepage = 'https://customer.io/'
s.license = { :file => '../LICENSE' }
Expand Down
2 changes: 1 addition & 1 deletion lib/customer_io_plugin_version.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Don't modify this line - it's automatically updated
const version = "1.2.1";
const version = "1.2.2";

0 comments on commit f514174

Please sign in to comment.