|
|
@ -156,9 +156,8 @@ class Nearby {
|
|
|
|
/// Convinience method
|
|
|
|
/// Convinience method
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Asks location permission
|
|
|
|
/// Asks location permission
|
|
|
|
Future<void> askLocationPermission() async => await _channel.invokeMethod(
|
|
|
|
void askLocationPermission() =>
|
|
|
|
'askLocationPermission',
|
|
|
|
_channel.invokeMethod('askLocationPermission');
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Convinience method
|
|
|
|
/// Convinience method
|
|
|
|
///
|
|
|
|
///
|
|
|
@ -171,21 +170,18 @@ class Nearby {
|
|
|
|
/// Convinience method
|
|
|
|
/// Convinience method
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Asks external storage permission, required for file
|
|
|
|
/// Asks external storage permission, required for file
|
|
|
|
Future<void> askExternalStoragePermission() async =>
|
|
|
|
void askExternalStoragePermission() =>
|
|
|
|
await _channel.invokeMethod(
|
|
|
|
_channel.invokeMethod('askExternalStoragePermission');
|
|
|
|
'askExternalStoragePermission',
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Convinience method
|
|
|
|
/// Convinience method
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Use this instead of calling both [askLocationPermission()] and [askExternalStoragePermission()]
|
|
|
|
/// Use this instead of calling both [askLocationPermission()] and [askExternalStoragePermission()]
|
|
|
|
Future<void> askLocationAndExternalStoragePermission() async =>
|
|
|
|
void askLocationAndExternalStoragePermission() =>
|
|
|
|
await _channel.invokeMethod(
|
|
|
|
_channel.invokeMethod('askLocationAndExternalStoragePermission');
|
|
|
|
'askLocationAndExternalStoragePermission',
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Start Advertising, Discoverers would be able to discover this advertiser.
|
|
|
|
/// Start Advertising, Discoverers would be able to discover this advertiser.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
|
|
|
|
/// [serviceId] is a unique identifier for your app, its recommended to use your app package name only, it cannot be null
|
|
|
|
/// [userNickName] and [strategy] should not be null
|
|
|
|
/// [userNickName] and [strategy] should not be null
|
|
|
|
Future<bool> startAdvertising(
|
|
|
|
Future<bool> startAdvertising(
|
|
|
|
String userNickName,
|
|
|
|
String userNickName,
|
|
|
@ -193,8 +189,9 @@ class Nearby {
|
|
|
|
@required OnConnctionInitiated onConnectionInitiated,
|
|
|
|
@required OnConnctionInitiated onConnectionInitiated,
|
|
|
|
@required OnConnectionResult onConnectionResult,
|
|
|
|
@required OnConnectionResult onConnectionResult,
|
|
|
|
@required OnDisconnected onDisconnected,
|
|
|
|
@required OnDisconnected onDisconnected,
|
|
|
|
|
|
|
|
String serviceId = "com.pkmnapps.nearby_connections",
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
assert(userNickName != null && strategy != null);
|
|
|
|
assert(userNickName != null && strategy != null && serviceId != null);
|
|
|
|
|
|
|
|
|
|
|
|
this._advertConnectionInitiated = onConnectionInitiated;
|
|
|
|
this._advertConnectionInitiated = onConnectionInitiated;
|
|
|
|
this._advertConnectionResult = onConnectionResult;
|
|
|
|
this._advertConnectionResult = onConnectionResult;
|
|
|
@ -202,7 +199,8 @@ class Nearby {
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod('startAdvertising', <String, dynamic>{
|
|
|
|
return await _channel.invokeMethod('startAdvertising', <String, dynamic>{
|
|
|
|
'userNickName': userNickName,
|
|
|
|
'userNickName': userNickName,
|
|
|
|
'strategy': strategy.index
|
|
|
|
'strategy': strategy.index,
|
|
|
|
|
|
|
|
'serviceId': serviceId,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -218,20 +216,23 @@ class Nearby {
|
|
|
|
|
|
|
|
|
|
|
|
/// Start Discovery, You will now be able to discover the advertisers now.
|
|
|
|
/// Start Discovery, You will now be able to discover the advertisers now.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
|
|
|
|
/// [serviceId] is a unique identifier for your app, its recommended to use your app package name only, it cannot be null
|
|
|
|
/// [userNickName] and [strategy] should not be null
|
|
|
|
/// [userNickName] and [strategy] should not be null
|
|
|
|
Future<bool> startDiscovery(
|
|
|
|
Future<bool> startDiscovery(
|
|
|
|
String userNickName,
|
|
|
|
String userNickName,
|
|
|
|
Strategy strategy, {
|
|
|
|
Strategy strategy, {
|
|
|
|
@required OnEndpointFound onEndpointFound,
|
|
|
|
@required OnEndpointFound onEndpointFound,
|
|
|
|
@required OnEndpointLost onEndpointLost,
|
|
|
|
@required OnEndpointLost onEndpointLost,
|
|
|
|
|
|
|
|
String serviceId = "com.pkmnapps.nearby_connections",
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
assert(userNickName != null && strategy != null);
|
|
|
|
assert(userNickName != null && strategy != null && serviceId != null);
|
|
|
|
this._onEndpointFound = onEndpointFound;
|
|
|
|
this._onEndpointFound = onEndpointFound;
|
|
|
|
this._onEndpointLost = onEndpointLost;
|
|
|
|
this._onEndpointLost = onEndpointLost;
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod('startDiscovery', <String, dynamic>{
|
|
|
|
return await _channel.invokeMethod('startDiscovery', <String, dynamic>{
|
|
|
|
'userNickName': userNickName,
|
|
|
|
'userNickName': userNickName,
|
|
|
|
'strategy': strategy.index
|
|
|
|
'strategy': strategy.index,
|
|
|
|
|
|
|
|
'serviceId': serviceId,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|