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

+1-1
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

+1-1
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

+10-2
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

+18-8
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

+5-5
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

+3
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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'chirpsdk'
1+
rootProject.name = 'chirp_flutter'

android/src/main/AndroidManifest.xml

+1-8
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

+10-25
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-
}

example/.gitignore

+7-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Miscellaneous
22
*.class
3-
*.lock
43
*.log
54
*.pyc
65
*.swp
@@ -16,8 +15,10 @@
1615
*.iws
1716
.idea/
1817

19-
# Visual Studio Code related
20-
.vscode/
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
2122

2223
# Flutter/Dart/Pub related
2324
**/doc/api/
@@ -26,46 +27,10 @@
2627
.packages
2728
.pub-cache/
2829
.pub/
29-
build/
30+
/build/
3031

31-
# Android related
32-
**/android/**/gradle-wrapper.jar
33-
**/android/.gradle
34-
**/android/captures/
35-
**/android/gradlew
36-
**/android/gradlew.bat
37-
**/android/local.properties
38-
**/android/**/GeneratedPluginRegistrant.java
39-
40-
# iOS/XCode related
41-
**/ios/**/*.mode1v3
42-
**/ios/**/*.mode2v3
43-
**/ios/**/*.moved-aside
44-
**/ios/**/*.pbxuser
45-
**/ios/**/*.perspectivev3
46-
**/ios/**/*sync/
47-
**/ios/**/.sconsign.dblite
48-
**/ios/**/.tags*
49-
**/ios/**/.vagrant/
50-
**/ios/**/DerivedData/
51-
**/ios/**/Icon?
52-
**/ios/**/Pods/
53-
**/ios/**/.symlinks/
54-
**/ios/**/profile
55-
**/ios/**/xcuserdata
56-
**/ios/.generated/
57-
**/ios/Flutter/App.framework
58-
**/ios/Flutter/Flutter.framework
59-
**/ios/Flutter/Generated.xcconfig
60-
**/ios/Flutter/app.flx
61-
**/ios/Flutter/app.zip
62-
**/ios/Flutter/flutter_assets/
63-
**/ios/ServiceDefinitions.json
64-
**/ios/Runner/GeneratedPluginRegistrant.*
32+
# Web related
33+
lib/generated_plugin_registrant.dart
6534

6635
# Exceptions to above rules.
67-
!**/ios/**/default.mode1v3
68-
!**/ios/**/default.mode2v3
69-
!**/ios/**/default.pbxuser
70-
!**/ios/**/default.perspectivev3
7136
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

example/.metadata

+1-1
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: app

example/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# ChirpSDK Example
1+
# Chirp Flutter Example
22

3-
Demonstrates how to use the ChirpSDK plugin.
3+
Demonstrates how to use the Chirp Flutter plugin.
44

55
## Getting Started
66

example/android/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java

example/android/app/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {
88

99
def flutterRoot = localProperties.getProperty('flutter.sdk')
1010
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
11+
throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
1212
}
1313

1414
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 27
29+
compileSdkVersion 28
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
@@ -38,12 +38,12 @@ android {
3838

3939
defaultConfig {
4040
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41-
applicationId "io.chirp.chirpsdkexample"
41+
applicationId "io.chirp.chirp_flutter_example"
4242
minSdkVersion 16
43-
targetSdkVersion 27
43+
targetSdkVersion 28
4444
versionCode flutterVersionCode.toInteger()
4545
versionName flutterVersionName
46-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
46+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4747
}
4848

4949
buildTypes {
@@ -62,6 +62,6 @@ flutter {
6262
dependencies {
6363
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6464
testImplementation 'junit:junit:4.12'
65-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
66-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
65+
androidTestImplementation 'androidx.test:runner:1.1.1'
66+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
6767
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.chirp.chirp_flutter_example">
3+
<!-- Flutter needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>

0 commit comments

Comments
 (0)