diff --git a/CHANGELOG.md b/CHANGELOG.md index ba3afc7..45eb684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.8 + +* fix issue on iOS + ## 1.0.7 * update readme diff --git a/example/lib/main.dart b/example/lib/main.dart index bbd8a65..9c1442e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:device_info/device_info.dart'; import 'package:flutter/material.dart'; import 'package:flutter_nearby_connections/flutter_nearby_connections.dart'; +import 'package:flutter_udid/flutter_udid.dart'; import 'package:fluttertoast/fluttertoast.dart'; void main() { @@ -105,6 +106,10 @@ Future _getId() async { } } +Future _getDeviceID() async { + return await FlutterUdid.udid; +} + class _DevicesListScreenState extends State { List devices = []; List connectedDevices = []; @@ -294,11 +299,12 @@ class _DevicesListScreenState extends State { } void init() async { + String deviceId = await _getId(); nearbyService = NearbyService(); await nearbyService.init( serviceType: 'mp-connection', strategy: Strategy.P2P_CLUSTER, - callback: (isRunning) async{ + callback: (isRunning) async { if (isRunning) { if (widget.deviceType == DeviceType.browser) { await nearbyService.stopBrowsingForPeers(); @@ -315,14 +321,18 @@ class _DevicesListScreenState extends State { subscription = nearbyService.stateChangedSubscription(callback: (devicesList) { devicesList?.forEach((element) { - if(element.state == SessionState.connected){ - nearbyService.stopBrowsingForPeers(); - }else{ - nearbyService.startBrowsingForPeers(); - } print( " deviceId: ${element.deviceId} | deviceName: ${element.deviceName} | state: ${element.state}"); + + if (Platform.isAndroid) { + if (element.state == SessionState.connected) { + nearbyService.stopBrowsingForPeers(); + } else { + nearbyService.startBrowsingForPeers(); + } + } }); + setState(() { devices.clear(); devices.addAll(devicesList); diff --git a/pubspec.yaml b/pubspec.yaml index c6fc12d..595ce90 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_nearby_connections description: Flutter plugin supports peer-to-peer connectivity and discovers nearby devices for Android and IOS -version: 1.0.7 +version: 1.0.8 author: vn.apnic@gmail.com homepage: https://github.com/VNAPNIC/flutter_nearby_connections