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

Commit f2c29bb

Browse files
authored
Merge pull request #20 from chirp/feature/ios-3.6.0
iOS 3.6.0
2 parents 9a3b957 + 64382f9 commit f2c29bb

40 files changed

+598
-592
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

.metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
7+
revision: 1946fc4da0f80c522d7e3ae7d4f7309908ed86f2
88
channel: dev
99

1010
project_type: plugin

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# Chirp SDK Flutter
1+
# Chirp for Flutter
22

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

513
- Upgrade to Android v3.9.5
614
- 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/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
group 'io.chirp.chirpsdk'
1+
group 'io.chirp.chirp_flutter'
22
version '1.0'
33

44
buildscript {
@@ -9,7 +9,7 @@ buildscript {
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.3.2'
12+
classpath 'com.android.tools.build:gradle:3.5.0'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
@@ -28,14 +28,14 @@ apply plugin: 'com.android.library'
2828
apply plugin: 'kotlin-android'
2929

3030
android {
31-
compileSdkVersion 27
31+
compileSdkVersion 28
3232

3333
sourceSets {
3434
main.java.srcDirs += 'src/main/kotlin'
3535
}
3636
defaultConfig {
3737
minSdkVersion 16
38-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
38+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3939
}
4040
lintOptions {
4141
disable 'InvalidPackage'
@@ -44,5 +44,5 @@ android {
4444

4545
dependencies {
4646
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
47-
implementation 'io.chirp:chirpsdk:3.10.1'
47+
implementation 'io.chirp:chirpsdk:3.10.0'
4848
}

android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.enableR8=true
3+
android.useAndroidX=true
4+
android.enableJetifier=true

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'chirpsdk'
1+
rootProject.name = 'chirp_flutter'
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="io.chirp.chirpsdk">
3-
4-
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
5-
<uses-permission android:name="android.permission.RECORD_AUDIO" />
6-
7-
<uses-permission android:name="android.permission.INTERNET" />
8-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
9-
2+
package="io.chirp.chirp_flutter">
103
</manifest>

android/src/main/kotlin/io/chirp/chirpsdk/ChirpsdkPlugin.kt renamed to android/src/main/kotlin/io/chirp/chirp_flutter/ChirpFlutterPlugin.kt

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.chirp.chirpsdk
1+
package io.chirp.chirp_flutter
22

33
import android.app.Activity
44

@@ -11,28 +11,28 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
1111
import io.flutter.plugin.common.MethodChannel.Result
1212
import io.flutter.plugin.common.PluginRegistry.Registrar
1313

14+
import io.chirp.chirpsdk.ChirpSDK
1415
import io.chirp.chirpsdk.interfaces.ChirpEventListener
1516
import io.chirp.chirpsdk.models.ChirpSDKState
1617
import io.chirp.chirpsdk.models.ChirpError
1718
import io.chirp.chirpsdk.models.ChirpErrorCode
1819

1920

20-
class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
21+
class ChirpFlutterPlugin(private val activity: Activity) : MethodCallHandler {
2122

2223
val stateStreamHandler = StateStreamHandler()
2324
val sendingStreamHandler = SendingStreamHandler()
2425
val sentStreamHandler = SentStreamHandler()
2526
val receivingStreamHandler = ReceivingStreamHandler()
2627
val receivedStreamHandler = ReceivedStreamHandler()
27-
val errorStreamHandler = ErrorStreamHandler()
2828

2929
lateinit var chirpSDK: ChirpSDK
3030

3131
companion object {
3232

3333
@JvmStatic
3434
fun registerWith(registrar: Registrar) {
35-
val instance = ChirpsdkPlugin(registrar.activity())
35+
val instance = ChirpFlutterPlugin(registrar.activity())
3636
val methodChannel = MethodChannel(registrar.messenger(), "chirp.io/methods")
3737
methodChannel.setMethodCallHandler(instance)
3838
val stateChannel = EventChannel(registrar.messenger(), "chirp.io/events/state")
@@ -45,8 +45,6 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
4545
receivingChannel.setStreamHandler(instance.receivingStreamHandler)
4646
val receivedChannel = EventChannel(registrar.messenger(), "chirp.io/events/received")
4747
receivedChannel.setStreamHandler(instance.receivedStreamHandler)
48-
val errorsChannel = EventChannel(registrar.messenger(), "chirp.io/events/errors")
49-
errorsChannel.setStreamHandler(instance.errorStreamHandler)
5048
}
5149
}
5250

@@ -64,7 +62,11 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
6462
val appKey = arguments["key"] as String
6563
val appSecret = arguments["secret"] as String
6664
chirpSDK = ChirpSDK(activity, appKey, appSecret)
67-
result.success(ChirpErrorCode.CHIRP_SDK_OK.code)
65+
if (chirpSDK == null) {
66+
result.error("-1", "Failed to initialise ChirpSDK", null)
67+
} else {
68+
result.success(ChirpErrorCode.CHIRP_SDK_OK.code)
69+
}
6870
}
6971

7072
private fun version(call: MethodCall, result: Result) {
@@ -133,8 +135,8 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
133135
result.error(error.code.toString(), error.message, null)
134136
return
135137
}
136-
result.success(error.code)
137138
setCallbacks()
139+
result.success(error.code)
138140
}
139141

140142
private fun start(call: MethodCall, result: Result) {
@@ -312,20 +314,3 @@ class ReceivedStreamHandler : StreamHandler {
312314
eventSink = null
313315
}
314316
}
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)