Skip to content

Commit

Permalink
Merge pull request #133 from RodrigoSMarques/dev
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
RodrigoSMarques authored Dec 18, 2021
2 parents 5262bd2 + 2e4c792 commit a256e68
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 249 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 4.0.0
* Migrate maven repository from jcenter to mavenCentral.
* Updated compile & target SDK to Android API 31.
* Updated minSdkVersion to Android API 21.
* Updated example app Android compileSdkVersion to 31.
* Removed support for the V1 Android embedding.
* Deprecate Referral rewards SDK Methods (loadRewards, redeemRewards, getCreditHistory)
* Removed Referral rewards SDK Methods from example app
* Updated Native `Android` and `iOS` SDKs:
**Android Native SDK Update 5.0.15 - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases)
**iOS Native SDK Update 1.40.2 - [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases)

## 3.5.0
* Updated Native `Android` and `iOS` SDKs:
**Android Native SDK Update 5.0.14 - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases)
Expand Down
100 changes: 1 addition & 99 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ Add key value pairs to all requests
FlutterBranchSdk.setRequestMetadata(requestMetadataKey, requestMetadataValue);
```


### Set time window (in Hours) for SKAdNetwork callouts (iOS only)
By default, Branch limits calls to SKAdNetwork to within 72 hours after first install.

Expand All @@ -421,104 +420,7 @@ In `ios/Runner/Info.plist`, you should have something like:
<true/>
```

### Referral System Rewarding Functionality
Reward balances change randomly on the backend when certain actions are taken (defined by your rules), so you'll need to make an asynchronous call to retrieve the balance.

Read more here: [https://blog.branch.io/how-to-build-an-optimized-referral-program-for-your-mobile-app/](https://blog.branch.io/how-to-build-an-optimized-referral-program-for-your-mobile-app/)

#### Get Reward Balance
Reward balances change randomly on the backend when certain actions are taken (defined by your rules), so you'll need to make call to retrieve the balance. Here is the syntax:

***optional parameter***: bucket - value containing the name of the referral bucket to attempt to redeem credits from

```dart
BranchResponse response =
await FlutterBranchSdk.loadRewards();
if (response.success) {
credits = response.result;
print('Crédits');
} else {
print('Credits error: ${response.errorMessage}');
}
```

#### Redeem All or Some of the Reward Balance (Store State)
Redeeming credits allows users to cash in the credits they've earned. Upon successful redemption, the user's balance will be updated reflecting the deduction.

***optional parameter***: bucket - value containing the name of the referral bucket to attempt to redeem credits from

```dart
BranchResponse response =
await FlutterBranchSdk.redeemRewards(count: 5);
if (response.success) {
print('Redeeming Credits with success');
} else {
print('Redeeming Credits with error: ${response.errorMessage}');
}
```
#### Get Credit History
This call will retrieve the entire history of credits and redemptions from the individual user. To use this call, implement like so:

***optional parameter***: bucket - value containing the name of the referral bucket to attempt to redeem credits from

```dart
BranchResponse response =
await FlutterBranchSdk.getCreditHistory();
if (response.success) {
print('getCreditHistory with success. Records: ${(response.result as List).length}');
} else {
print('getCreditHistory with error: ${response.errorMessage}');
}
```
The response will return an list of map:

```json
[
{
"transaction": {
"date": "2014-10-14T01:54:40.425Z",
"id": "50388077461373184",
"bucket": "default",
"type": 0,
"amount": 5
},
"event" : {
"name": "event name",
"metadata": { your event metadata if present }
},
"referrer": "12345678",
"referree": null
},
{
"transaction": {
"date": "2014-10-14T01:55:09.474Z",
"id": "50388199301710081",
"bucket": "default",
"type": 2,
"amount": -3
},
"event" : {
"name": "event name",
"metadata": { your event metadata if present }
},
"referrer": null,
"referree": "12345678"
}
]
```
**referrer** : The id of the referring user for this credit transaction. Returns null if no referrer is involved. Note this id is the user id in a developer's own system that's previously passed to Branch's identify user API call.

**referree** : The id of the user who was referred for this credit transaction. Returns null if no referree is involved. Note this id is the user id in a developer's own system that's previously passed to Branch's identify user API call.

**type** : This is the type of credit transaction.

* 0 - A reward that was added automatically by the user completing an action or promo.
* 1 - A reward that was added manually.
* 2 - A redemption of credits that occurred through our API or SDKs.
* 3 - This is a very unique case where we will subtract credits automatically when we detect fraud.


### iOS 14+ App Tracking Transparency
### iOS 14+ App Tracking Transparency
Starting with iOS 14.5, iPadOS 14.5, and tvOS 14.5, you’ll need to receive the user’s permission through the AppTrackingTransparency framework to track them or access their device’s advertising identifier. Tracking refers to the act of linking user or device data collected from your app with user or device data collected from other companies’ apps, websites, or offline properties for targeted advertising or advertising measurement purposes. Tracking also refers to sharing user or device data with data brokers.

See: [https://developer.apple.com/app-store/user-privacy-and-data-use/](https://developer.apple.com/app-store/user-privacy-and-data-use/)
Expand Down
14 changes: 7 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ version '1.0'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 31

defaultConfig {
minSdkVersion 16
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand All @@ -34,9 +34,9 @@ android {
}

dependencies {
implementation 'io.branch.sdk.android:library:5.0.14'
implementation 'io.branch.sdk.android:library:5.0.15'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:16+'
implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.3.1'
}
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-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.NewIntentListener;
import io.flutter.plugin.common.PluginRegistry.Registrar;

public class FlutterBranchSdkPlugin implements FlutterPlugin, MethodCallHandler, StreamHandler, NewIntentListener, ActivityAware,
Application.ActivityLifecycleCallbacks {
Expand All @@ -64,18 +63,6 @@ public class FlutterBranchSdkPlugin implements FlutterPlugin, MethodCallHandler,
/**---------------------------------------------------------------------------------------------
Plugin registry
--------------------------------------------------------------------------------------------**/
public static void registerWith(Registrar registrar) {
LogUtils.debug(DEBUG_NAME, "registerWith call");
if (registrar.activity() == null) {
// When a background flutter view tries to register the plugin, the registrar has no activity.
// We stop the registration process as this plugin is foreground only.
return;
}
FlutterBranchSdkPlugin plugin = new FlutterBranchSdkPlugin();
plugin.setupChannels(registrar.messenger(), registrar.activity().getApplicationContext());
plugin.setActivity(registrar.activity());
registrar.addNewIntentListener(plugin);
}

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
Expand Down
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 31

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,8 +34,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "br.com.rsmarques.flutter_branch_sdk_example"
minSdkVersion 16
targetSdkVersion 30
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand All @@ -12,7 +12,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
107 changes: 0 additions & 107 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -459,113 +459,6 @@ class _HomePageState extends State<HomePage> {
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
child: CustomButton(
child: Text('Viewing Credits'),
onPressed: () async {
bool isUserIdentified =
await FlutterBranchSdk.isUserIdentified();

if (!isUserIdentified) {
showSnackBar(
context: context,
message:
'User not identified. Call setIdentity() before.');
return;
}

int credits = 0;
BranchResponse response =
await FlutterBranchSdk.loadRewards();
if (response.success) {
credits = response.result;
print('Crédits');
showSnackBar(
context: context, message: 'Credits: $credits');
} else {
showSnackBar(
context: context,
message:
'Credits error: ${response.errorMessage}');
}
},
),
),
SizedBox(
width: 10,
),
Expanded(
child: CustomButton(
child: Text('Redeeming Credits'),
onPressed: () async {
bool isUserIdentified =
await FlutterBranchSdk.isUserIdentified();

if (!isUserIdentified) {
showSnackBar(
context: context,
message:
'User not identified. Call setIdentity() before.');
return;
}

bool success = false;
BranchResponse response =
await FlutterBranchSdk.redeemRewards(count: 5);
if (response.success) {
success = response.result;
print('Redeeming Credits: $success');
showSnackBar(
context: context,
message: 'Redeeming Credits: $success');
} else {
print(
'Redeeming Credits error: ${response.errorMessage}');
showSnackBar(
context: context,
message:
'Redeeming Credits error: ${response.errorMessage}');
}
//success = await
},
),
),
],
),
CustomButton(
child: Text('Get Credits History'),
onPressed: () async {
bool isUserIdentified =
await FlutterBranchSdk.isUserIdentified();

if (!isUserIdentified) {
showSnackBar(
context: context,
message:
'User not identified. Call setIdentity() before.');
return;
}

BranchResponse response =
await FlutterBranchSdk.getCreditHistory();
if (response.success) {
print('Credits Hystory: ${response.result}');
showSnackBar(
context: context,
message:
'Check log for view Credit History. Records: ${(response.result as List).length}');
} else {
print(
'Get Credits History error: ${response.errorMessage}');
showSnackBar(
context: context,
message:
'Get Credits History error: ${response.errorMessage}');
}
}),
CustomButton(
child: Text('Generate Link'),
onPressed: generateLink,
Expand Down
Loading

0 comments on commit a256e68

Please sign in to comment.