Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This package works with in Android but not in ios #46

Open
ziagit opened this issue Feb 2, 2022 · 1 comment
Open

This package works with in Android but not in ios #46

ziagit opened this issue Feb 2, 2022 · 1 comment
Assignees

Comments

@ziagit
Copy link

ziagit commented Feb 2, 2022

I use pusher_client: ^2.0.0 it works without any problem with Android but when run my project on ios simulator I get error in the console.
when I run flutter run I get the following errors.


Xcode's output:
↳
    2 warnings generated.
    error: the following command failed with exit code 0 but produced no further output
    CompileC
    /Users/zia/Library/Developer/Xcode/DerivedData/Runner-hdzpmljlvwqzschdvjjsljzxqxtc/Build/Intermediates.noindex/
    Pods.build/Debug-iphonesimulator/location.build/Objects-normal/arm64/LocationPlugin.o
    /Users/zia/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/location-4.3.0/ios/Classes/LocationPlugin.m
    normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'location' from project 'Pods')
    /Users/zia/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_phone_direct_caller-2.1.0/ios/Classes/F
    lutterPhoneDirectCallerPlugin.m:24:22: warning: 'stringByAddingPercentEscapesUsingEncoding:' is deprecated:
    first deprecated in iOS 9.0 - Use -stringByAddingPercentEncodingWithAllowedCharacters: instead, which always
    uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent since each
    URL component or subcomponent has different rules for what characters are valid. [-Wdeprecated-declarations]
        number = [number stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                         ^
    In module 'UIKit' imported from /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Target Support
    Files/flutter_phone_direct_caller/flutter_phone_direct_caller-prefix.pch:2:
    In module 'Foundation' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.
    2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.
    2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h:599:1: note:
    'stringByAddingPercentEscapesUsingEncoding:' has been explicitly marked deprecated here
    - (nullable NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc API_DEPRECATED("Use
    -stringByAddingPercentEncodingWithAllowedCharacters: instead, which always uses the recommended UTF-8 encoding,
    and which encodes for a specific URL component or subcomponent since each URL component or subcomponent has
    different rules for what characters are valid.", macos(10.0,10.11), ios(2.0,9.0), watchos(2.0,2.0),
    tvos(9.0,9.0));
    ^
    /Users/zia/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_phone_direct_caller-2.1.0/ios/Classes/F
    lutterPhoneDirectCallerPlugin.m:30:51: warning: 'openURL:' is deprecated: first deprecated in iOS 10.0
    [-Wdeprecated-declarations]
        } else if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]]) {
                                                      ^~~~~~~
                                                      openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Target Support
    Files/flutter_phone_direct_caller/flutter_phone_direct_caller-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.
    2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:124:1: note: 'openURL:' has been
    explicitly marked deprecated here
    - (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0,
    10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
    ^
    2 warnings generated.
    /Users/zia/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_phone_direct_caller-2.1.0/ios/Classes/F
    lutterPhoneDirectCallerPlugin.m:24:22: warning: 'stringByAddingPercentEscapesUsingEncoding:' is deprecated:
    first deprecated in iOS 9.0 - Use -stringByAddingPercentEncodingWithAllowedCharacters: instead, which always
    uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent since each
    URL component or subcomponent has different rules for what characters are valid. [-Wdeprecated-declarations]
        number = [number stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                         ^
    In module 'UIKit' imported from /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Target Support
    Files/flutter_phone_direct_caller/flutter_phone_direct_caller-prefix.pch:2:
    In module 'Foundation' imported from
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.
    2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.
    2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h:599:1: note:
    'stringByAddingPercentEscapesUsingEncoding:' has been explicitly marked deprecated here
    - (nullable NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc API_DEPRECATED("Use
    -stringByAddingPercentEncodingWithAllowedCharacters: instead, which always uses the recommended UTF-8 encoding,
    and which encodes for a specific URL component or subcomponent since each URL component or subcomponent has
    different rules for what characters are valid.", macos(10.0,10.11), ios(2.0,9.0), watchos(2.0,2.0),
    tvos(9.0,9.0));
    ^
    /Users/zia/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_phone_direct_caller-2.1.0/ios/Classes/F
    lutterPhoneDirectCallerPlugin.m:30:51: warning: 'openURL:' is deprecated: first deprecated in iOS 10.0
    [-Wdeprecated-declarations]
        } else if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]]) {
                                                      ^~~~~~~
                                                      openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Target Support
    Files/flutter_phone_direct_caller/flutter_phone_direct_caller-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.
    2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:124:1: note: 'openURL:' has been
    explicitly marked deprecated here
    - (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0,
    10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
    ^
    2 warnings generated.
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:61:34:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WebSocketClient: class {
                                     ^~~~~
                                     AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:119:35:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WSStreamDelegate: class {
                                      ^~~~~
                                      AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:313:36:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WebSocketDelegate: class {
                                       ^~~~~
                                       AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:321:40:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WebSocketPongDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:326:44:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WebSocketAdvancedDelegate: class {
                                               ^~~~~
                                               AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:282:30:
    warning: 'withUnsafeMutableBytes' is deprecated: use `withUnsafeMutableBytes<R>(_:
    (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R` instead
                let _ = peerName.withUnsafeMutableBytes { (peerNamePtr: UnsafeMutablePointer<Int8>) in
                                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1326:14:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) }
                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1327:16:
    warning: 'init(bytes:)' is deprecated: use `init(_:)` instead
            return Data(bytes: digest).base64EncodedString()
                   ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:59:25:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            return try data.withUnsafeBytes { (bytes:UnsafePointer<UInt8>) -> Data in
                            ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:29:
    warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                            
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:140:14:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            data.withUnsafeBytes { (ptr:UnsafePointer<UInt8>) -> Void in
                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:61:34:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WebSocketClient: class {
                                     ^~~~~
                                     AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:119:35:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WSStreamDelegate: class {
                                      ^~~~~
                         ...
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:282:30:
    warning: 'withUnsafeMutableBytes' is deprecated: use `withUnsafeMutableBytes<R>(_:
    (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R` instead
                let _ = peerName.withUnsafeMutableBytes { (peerNamePtr: UnsafeMutablePointer<Int8>) in
                                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1326:14:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) }
                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1327:16:
    warning: 'init(bytes:)' is deprecated: use `init(_:)` instead
            return Data(bytes: digest).base64EncodedString()
                   ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:59:25:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            return try data.withUnsafeBytes { (bytes:UnsafePointer<UInt8>) -> Data in
                            ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:29:
    warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57:
    note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid
    only for the duration of the call to 'init(_:)'
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^~~~~~~
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57:
    note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to
    buffer pointer valid for a defined scope
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^
...
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/Compression.swift:140:14:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            data.withUnsafeBytes { (ptr:UnsafePointer<UInt8>) -> Void in
                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:61:34:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WebSocketClient: class {
                                     ^~~~~
                                     AnyObject
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:119:35:
    warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    public protocol WSStreamDelegate: class {
                                      ^~~~~
     ...                                
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1326:14:
    warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R)
    rethrows -> R` instead
            data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) }
                 ^
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1327:16:
    warning: 'init(bytes:)' is deprecated: use `init(_:)` instead
            return Data(bytes: digest).base64EncodedString()
                   ^
    ld: in
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Sodium/Sodium/libsodium/libsodium-ios.a(libsodium_la-ae
    ad_xchacha20poly1305.o), building for iOS Simulator, but linking in object file built for iOS, for architecture
    arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a
    placeholder team ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from
    project 'Runner')
    /Users/zia/Desktop/projects/com_tingsapp_mover/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment
    target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0
    to 15.2.99. (in target 'leveldb-library' from project 'Pods')


Could not build the application for the simulator.
Error launching application on iPhone 13.

I could not find any related message in the above error This is flutter --version

% flutter --version 
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (7 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

and this is my 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>Tingsapp Mover</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>com_tingsapp_mover</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>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>UIViewControllerBasedStatusBarAppearance</key>
	<true/>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>This app require to access your location when open</string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>tel</string>
		<string>https</string>
		<string>http</string>
	</array>
	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSExceptionDomains</key>
		<dict>
			<key>tingsapp.com</key>
			<dict>
				<key>NSExceptionAllowsInsecureHTTPLoads</key>
				<true/>
				<key>NSIncludesSubdomains</key>
				<true/>
			</dict>
		</dict>
	</dict>
</dict>
</plist>

This is how I connect to pusher

import 'package:pusher_client/pusher_client.dart';
...
...

class Messages extends StatefulWidget {
  final Room room;
  final int user;
  const Messages({Key? key, required this.room, required this.user})
      : super(key: key);

  @override
  _MessagesState createState() => _MessagesState();
}

class _MessagesState extends State<Messages> {
  TextEditingController _messageController = TextEditingController();
  PusherClient? pusher;
  Channel? channel;
  List<Message> messages = [];

  @override
  void initState() {
    _initPusher();
    super.initState();
  }

  @override
  void dispose() {
    channel?.unbind('chat-event');
    pusher?.unsubscribe('chat.' + widget.room.id.toString());
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Message")),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            FutureBuilder(
              future: _get(),
              builder: (context, snapshot) {
                if (snapshot.hasData ||
                    snapshot.connectionState == ConnectionState.done) {
                  return Expanded(
                    child: ListView.builder(
                      reverse: true,
                      padding: EdgeInsets.only(top: 12, left: 12, right: 12),
                      shrinkWrap: true,
                      itemCount: messages.length,
                      itemBuilder: (context, index) {
                        return Column(
                          children: [
                            _buildMyMessage(messages[index]) != null
                                ? MyMessageCard(
                                    message: _buildMyMessage(messages[index]))
                                : Container(),
                            _buildFriendMessage(messages[index]) != null
                                ? FriendMessageCard(
                                    message:
                                        _buildFriendMessage(messages[index]))
                                : Container(),
                          ],
                        );
                      },
                    ),
                  );
                } else if (snapshot.hasError) {
                  return Padding(
                    child: Text("Error: ${snapshot.error}"),
                    padding: EdgeInsets.only(top: 8),
                  );
                } else {
                  return Center(
                      child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: circularProgress(context)));
                }
              },
            ),
            Container(
              padding: EdgeInsets.all(5),
              margin: EdgeInsets.all(5),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Expanded(
                    child: SizedBox(
                      height: 55,
                      child: Card(
                        elevation: 2,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(50),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 18.0, right: 18.0, top: 3),
                          child: TextFormField(
                            controller: _messageController,
                            decoration: InputDecoration(
                                border: InputBorder.none,
                                isDense: true,
                                hintText: 'Message'),
                          ),
                        ),
                      ),
                    ),
                  ),
                  SizedBox(
                    width: 55,
                    height: 55,
                    child: Card(
                      color: Tingsapp.primary,
                      elevation: 2,
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(50),
                      ),
                      child: InkWell(
                          onTap: () => _send(context),
                          child: Icon(
                            Icons.send,
                            color: Colors.white,
                          )),
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }

  _send(context) async {
    Api api = new Api();
    try {
      var response = await api.post(
        jsonEncode(
          <String, dynamic>{
            'message': _messageController.text,
          },
        ),
        "chat/room/" + "${widget.room.id}" + "/message",
      );
      if (response.statusCode == 200) {
        _messageController.text = "";
        _get();
      }
    } catch (err) {
      showSnackbar(context, '${err.toString()}');
    }
  }

  Future _get() async {
    Api api = new Api();
    try {
      var response =
          await api.get("chat/room/" + "${widget.room.id}" + "/messages");
      if (response.statusCode == 200) {
        var jsonData = jsonDecode(response.body);
        var messageList =
            (jsonData as List).map((e) => Message.fromJson(e)).toList();
        messages = messageList;
        return messages;
      }
      return [];
    } catch (err) {
      showSnackbar(context, '${err.toString()}');
    }
  }
  Future<void> _initPusher() async {
    Store store = new Store();
    String token = await store.read('token');
    try {
      pusher = PusherClient(
        pusherKey,
        PusherOptions(
          host: broadcastPath,
          encrypted: false,
          auth: PusherAuth(
            broadcastPath + "/broadcasting/auth",
            headers: {
              'Content-Type': 'application/json',
              'Authorization': 'Bearer $token'
            },
          ),
          cluster: 'eu',
        ),
        enableLogging: true,
      );
      channel = pusher?.subscribe("private-chat." + widget.room.id.toString());

      pusher?.onConnectionStateChange((state) {
        print(
            "previousState: ${state?.previousState}, currentState: ${state?.currentState}");
      });

      pusher?.onConnectionError((error) {
        print("error: ${error?.message}");
      });

      channel?.bind('chat-event', (event) {
        setState(() {});
      });
    } catch (e) {
      print(e.toString());
    }
  }
}

But the moment I comment out the above file and pusher_client: ^2.0.0 in pubspec.yaml and then run flutter run my application gets run on ios simulator.
Can anyone help please

@Mikle1c
Copy link

Mikle1c commented Feb 8, 2022

answered here

https://stackoverflow.com/questions/70959271/flutter-pusher-works-in-android-but-not-in-ios/71040583#71040583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants