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

Commit

Permalink
Merge pull request #20 from chirp/feature/ios-3.6.0
Browse files Browse the repository at this point in the history
iOS 3.6.0
  • Loading branch information
dinuchiriac authored Oct 24, 2019
2 parents 9a3b957 + 64382f9 commit f2c29bb
Show file tree
Hide file tree
Showing 40 changed files with 598 additions and 592 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ xcuserdata/
*.aar
*.framework

example/ios/Flutter/flutter_export_environment.sh'
flutter_export_environment.sh
2 changes: 1 addition & 1 deletion .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
revision: 1946fc4da0f80c522d7e3ae7d4f7309908ed86f2
channel: dev

project_type: plugin
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Chirp SDK Flutter
# Chirp for Flutter

## 0.4.0 - beta
## 1.0.0 - 24/10/19

- Rename package to `chirp_flutter`
- Update error handling to use `try/catch`
- Fix bug so callbacks are on the main thread
- Upgrade to Android v3.10.1
- Upgrade to iOS v3.6.0

## 0.4.0 - 23/07/19

- Upgrade to Android v3.9.5
- Upgrade to iOS v3.5.2
Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ChirpSDK (Beta)
# ChirpSDK

Send data with sound.

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

await ChirpSDK.init(_appKey, _appSecret);
await ChirpSDK.setConfig(_appConfig);
await ChirpSDK.start();
try {
await ChirpSDK.init(_appKey, _appSecret);
await ChirpSDK.setConfig(_appConfig);
await ChirpSDK.start();
} catch(err) {
errorMessage = "ChirpError: ${err.message}"
}


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

String identifier = "hello";
var payload = new Uint8List.fromList(identifier.codeUnits);
await ChirpSDK.send(payload);
try {
String identifier = "hello";
var payload = new Uint8List.fromList(identifier.codeUnits);
await ChirpSDK.send(payload);
} catch(err) {
errorMessage = "ChirpError: ${err.message}"
}


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

## Receiving
Expand Down
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group 'io.chirp.chirpsdk'
group 'io.chirp.chirp_flutter'
version '1.0'

buildscript {
Expand All @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -28,14 +28,14 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
Expand All @@ -44,5 +44,5 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'io.chirp:chirpsdk:3.10.1'
implementation 'io.chirp:chirpsdk:3.10.0'
}
3 changes: 3 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'chirpsdk'
rootProject.name = 'chirp_flutter'
9 changes: 1 addition & 8 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.chirp.chirpsdk">

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

package="io.chirp.chirp_flutter">
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.chirp.chirpsdk
package io.chirp.chirp_flutter

import android.app.Activity

Expand All @@ -11,28 +11,28 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.Registrar

import io.chirp.chirpsdk.ChirpSDK
import io.chirp.chirpsdk.interfaces.ChirpEventListener
import io.chirp.chirpsdk.models.ChirpSDKState
import io.chirp.chirpsdk.models.ChirpError
import io.chirp.chirpsdk.models.ChirpErrorCode


class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
class ChirpFlutterPlugin(private val activity: Activity) : MethodCallHandler {

val stateStreamHandler = StateStreamHandler()
val sendingStreamHandler = SendingStreamHandler()
val sentStreamHandler = SentStreamHandler()
val receivingStreamHandler = ReceivingStreamHandler()
val receivedStreamHandler = ReceivedStreamHandler()
val errorStreamHandler = ErrorStreamHandler()

lateinit var chirpSDK: ChirpSDK

companion object {

@JvmStatic
fun registerWith(registrar: Registrar) {
val instance = ChirpsdkPlugin(registrar.activity())
val instance = ChirpFlutterPlugin(registrar.activity())
val methodChannel = MethodChannel(registrar.messenger(), "chirp.io/methods")
methodChannel.setMethodCallHandler(instance)
val stateChannel = EventChannel(registrar.messenger(), "chirp.io/events/state")
Expand All @@ -45,8 +45,6 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
receivingChannel.setStreamHandler(instance.receivingStreamHandler)
val receivedChannel = EventChannel(registrar.messenger(), "chirp.io/events/received")
receivedChannel.setStreamHandler(instance.receivedStreamHandler)
val errorsChannel = EventChannel(registrar.messenger(), "chirp.io/events/errors")
errorsChannel.setStreamHandler(instance.errorStreamHandler)
}
}

Expand All @@ -64,7 +62,11 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
val appKey = arguments["key"] as String
val appSecret = arguments["secret"] as String
chirpSDK = ChirpSDK(activity, appKey, appSecret)
result.success(ChirpErrorCode.CHIRP_SDK_OK.code)
if (chirpSDK == null) {
result.error("-1", "Failed to initialise ChirpSDK", null)
} else {
result.success(ChirpErrorCode.CHIRP_SDK_OK.code)
}
}

private fun version(call: MethodCall, result: Result) {
Expand Down Expand Up @@ -133,8 +135,8 @@ class ChirpsdkPlugin(private val activity: Activity) : MethodCallHandler {
result.error(error.code.toString(), error.message, null)
return
}
result.success(error.code)
setCallbacks()
result.success(error.code)
}

private fun start(call: MethodCall, result: Result) {
Expand Down Expand Up @@ -312,20 +314,3 @@ class ReceivedStreamHandler : StreamHandler {
eventSink = null
}
}

class ErrorStreamHandler : StreamHandler {
private var eventSink: EventSink? = null

override fun onListen(arguments: Any?, sink: EventSink) {
eventSink = sink
}

fun send(code: Int, message: String) {
eventSink?.success(mapOf("code" to code,
"message" to message))
}

override fun onCancel(arguments: Any?) {
eventSink = null
}
}
49 changes: 7 additions & 42 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
Expand All @@ -16,8 +15,10 @@
*.iws
.idea/

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

# Flutter/Dart/Pub related
**/doc/api/
Expand All @@ -26,46 +27,10 @@
.packages
.pub-cache/
.pub/
build/
/build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Web related
lib/generated_plugin_registrant.dart

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
2 changes: 1 addition & 1 deletion example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
revision: 1946fc4da0f80c522d7e3ae7d4f7309908ed86f2
channel: dev

project_type: app
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ChirpSDK Example
# Chirp Flutter Example

Demonstrates how to use the ChirpSDK plugin.
Demonstrates how to use the Chirp Flutter plugin.

## Getting Started

Expand Down
7 changes: 7 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
14 changes: 7 additions & 7 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {

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

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

android {
compileSdkVersion 27
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -38,12 +38,12 @@ android {

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

buildTypes {
Expand All @@ -62,6 +62,6 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
7 changes: 7 additions & 0 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.chirp.chirp_flutter_example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Loading

0 comments on commit f2c29bb

Please sign in to comment.