Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit daa025c

Browse files
authored
Merge pull request #25 from chirp/bug/ios-failed-decode
Fix failed decode crash on iOS
2 parents f2c29bb + 4c25be6 commit daa025c

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Chirp for Flutter
22

3+
## 1.0.1 - 07/01/20
4+
5+
- Fix iOS failed decode bug
6+
37
## 1.0.0 - 24/10/19
48

59
- Rename package to `chirp_flutter`

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ChirpSDK
22

3-
Send data with sound.
3+
Send data with sound - [chirp_flutter](https://pub.dev/packages/chirp_flutter)
44

55
## Getting Started
66

@@ -20,7 +20,7 @@ Copy and paste your Chirp app key, secret and chosen configuration into the
2020

2121
Please see the [example](https://github.com/chirp/chirp-flutter/tree/master/example)
2222
for a more detailed run through of how to use the Chirp SDK.
23-
For example the Chirp SDK async methods must called inside a Future async parent method.
23+
For example the Chirp SDK methods must be called inside a Future async parent method.
2424

2525
## Permissions
2626

ios/Classes/ChirpFlutterPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
@end
3737

3838
@interface ReceivedStreamHandler : NSObject<FlutterStreamHandler>
39-
- (void)send:(FlutterStandardTypedData *)data channel:(NSNumber *)channel;
39+
- (void)send:(FlutterStandardTypedData * _Nullable)data channel:(NSNumber *)channel;
4040
@end
4141

ios/Classes/ChirpFlutterPlugin.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,18 @@ - (void)setCallbacks {
105105

106106
[weakSelf.chirp setReceivedBlock:^(NSData * _Nullable data, NSUInteger channel)
107107
{
108-
/*------------------------------------------------------------------------------
109-
* receivedBlock is called when a receive event has completed.
110-
* If the payload was decoded successfully, it is passed in data.
111-
* Otherwise, data is null.
112-
*----------------------------------------------------------------------------*/
113-
[weakSelf.receivedStreamHandler send:[FlutterStandardTypedData typedDataWithBytes:data]
114-
channel:[NSNumber numberWithInteger:channel]];
108+
/*------------------------------------------------------------------------------
109+
* receivedBlock is called when a receive event has completed.
110+
* If the payload was decoded successfully, it is passed in data.
111+
* Otherwise, data is null.
112+
*----------------------------------------------------------------------------*/
113+
if (data) {
114+
[weakSelf.receivedStreamHandler send:[FlutterStandardTypedData typedDataWithBytes:data]
115+
channel:[NSNumber numberWithInteger:channel]];
116+
} else {
117+
[weakSelf.receivedStreamHandler send:[NSNull null]
118+
channel:[NSNumber numberWithInteger:channel]];
119+
}
115120
}];
116121
}
117122

@@ -347,7 +352,7 @@ - (FlutterError *_Nullable)onListenWithArguments:(id _Nullable)arguments eventSi
347352
return nil;
348353
}
349354

350-
- (void)send:(FlutterStandardTypedData *)data channel:(NSNumber *)channel {
355+
- (void)send:(FlutterStandardTypedData * _Nullable)data channel:(NSNumber *)channel {
351356
if (_eventSink) {
352357
NSDictionary *dictionary = @{ @"data": data, @"channel": channel };
353358
_eventSink(dictionary);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: chirp_flutter
22
description: Chirp enables your apps to send and receive information using sound.
3-
version: 1.0.0
3+
version: 1.0.1
44
author: Asio Ltd <developers@chirp.io>
55
homepage: https://github.com/chirp/chirp-flutter
66

0 commit comments

Comments
 (0)