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

Commit 865e771

Browse files
committed
Update to use Chirp iOS 3.6.0
1 parent 9a3b957 commit 865e771

File tree

12 files changed

+280
-209
lines changed

12 files changed

+280
-209
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ xcuserdata/
4646
*.aar
4747
*.framework
4848

49-
example/ios/Flutter/flutter_export_environment.sh'
49+
flutter_export_environment.sh

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Chirp SDK Flutter
22

3-
## 0.4.0 - beta
3+
## 1.0.0 - beta
4+
5+
- Update error handling to use `try/catch`
6+
- Fix bug so callbacks are on the main thread
7+
- Upgrade to Android v3.10.1
8+
- Upgrade to iOS v3.6.0
9+
10+
## 0.4.0 - 23/07/19
411

512
- Upgrade to Android v3.9.5
613
- Upgrade to iOS v3.5.2

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ChirpSDK (Beta)
1+
# ChirpSDK
22

33
Send data with sound.
44

@@ -9,9 +9,14 @@ Sign up at the Chirp [Developer Hub](https://developers.chirp.io/sign-up)
99
Copy and paste your Chirp app key, secret and chosen configuration into the
1010
[example application](https://github.com/chirp/chirp-flutter/tree/master/example)
1111

12-
await ChirpSDK.init(_appKey, _appSecret);
13-
await ChirpSDK.setConfig(_appConfig);
14-
await ChirpSDK.start();
12+
try {
13+
await ChirpSDK.init(_appKey, _appSecret);
14+
await ChirpSDK.setConfig(_appConfig);
15+
await ChirpSDK.start();
16+
} catch(err) {
17+
errorMessage = "ChirpError: ${err.message}"
18+
}
19+
1520

1621
Please see the [example](https://github.com/chirp/chirp-flutter/tree/master/example)
1722
for a more detailed run through of how to use the Chirp SDK.
@@ -35,12 +40,17 @@ Chirp SDKs accept data as an array of bytes, creating a versatile interface for
3540
However in most cases, Chirp is used to send a short identifier. Here is an example of how to send
3641
a short string with the Chirp SDK.
3742

38-
String identifier = "hello";
39-
var payload = new Uint8List.fromList(identifier.codeUnits);
40-
await ChirpSDK.send(payload);
43+
try {
44+
String identifier = "hello";
45+
var payload = new Uint8List.fromList(identifier.codeUnits);
46+
await ChirpSDK.send(payload);
47+
} catch(err) {
48+
errorMessage = "ChirpError: ${err.message}"
49+
}
50+
4151

4252
It is worth noting here that the send method will not block until the entire payload has been sent,
43-
but just as long as it takes to pass the message to the SDK. Please use the onSent callback for this
53+
but just as long as it takes to pass the message to the SDK. Please use the `onSent` callback for this
4454
purpose.
4555

4656
## Receiving

android/src/main/kotlin/io/chirp/chirpsdk/ChirpsdkPlugin.kt

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
2424
val sentStreamHandler = SentStreamHandler()
2525
val receivingStreamHandler = ReceivingStreamHandler()
2626
val receivedStreamHandler = ReceivedStreamHandler()
27-
val errorStreamHandler = ErrorStreamHandler()
2827

2928
lateinit var chirpSDK: ChirpSDK
3029

@@ -45,8 +44,6 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
4544
receivingChannel.setStreamHandler(instance.receivingStreamHandler)
4645
val receivedChannel = EventChannel(registrar.messenger(), "chirp.io/events/received")
4746
receivedChannel.setStreamHandler(instance.receivedStreamHandler)
48-
val errorsChannel = EventChannel(registrar.messenger(), "chirp.io/events/errors")
49-
errorsChannel.setStreamHandler(instance.errorStreamHandler)
5047
}
5148
}
5249

@@ -64,7 +61,11 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
6461
val appKey = arguments["key"] as String
6562
val appSecret = arguments["secret"] as String
6663
chirpSDK = ChirpSDK(activity, appKey, appSecret)
67-
result.success(ChirpErrorCode.CHIRP_SDK_OK.code)
64+
if (chirpSDK) {
65+
result.success(ChirpErrorCode.CHIRP_SDK_OK.code)
66+
} else {
67+
result.error(-1, "Failed to initialise ChirpSDK", null)
68+
}
6869
}
6970

7071
private fun version(call: MethodCall, result: Result) {
@@ -133,8 +134,8 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
133134
result.error(error.code.toString(), error.message, null)
134135
return
135136
}
136-
result.success(error.code)
137137
setCallbacks()
138+
result.success(error.code)
138139
}
139140

140141
private fun start(call: MethodCall, result: Result) {
@@ -312,20 +313,3 @@ class ReceivedStreamHandler : StreamHandler {
312313
eventSink = null
313314
}
314315
}
315-
316-
class ErrorStreamHandler : StreamHandler {
317-
private var eventSink: EventSink? = null
318-
319-
override fun onListen(arguments: Any?, sink: EventSink) {
320-
eventSink = sink
321-
}
322-
323-
fun send(code: Int, message: String) {
324-
eventSink?.success(mapOf("code" to code,
325-
"message" to message))
326-
}
327-
328-
override fun onCancel(arguments: Any?) {
329-
eventSink = null
330-
}
331-
}

0 commit comments

Comments
 (0)