Skip to content

Commit

Permalink
fix for android 12
Browse files Browse the repository at this point in the history
  • Loading branch information
JL-Vidinoti committed Oct 19, 2022
1 parent d5480bf commit b2a1031
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This plugin requires the Vidinoti SDK version >= 6.4.0
## What does the plugin

1. Add required dependencies in gradle files
2. Copy Java classes (Android services) `VidinotiInstanceIDListenerService` and `VidinotiFcmListenerService`
2. Copy Java classes (Android services) `VidinotiFcmListenerService`
3. Add the Android services to the `AndroidManifest.xml` file
4. In the "after prepare" hook scripts, it takes the `google-services.json` file and copy it to `platforms/android`
5. In the "after prepare" hook scripts, it takes the `google-services.json` file and extracts the Google app ID and key. It then writes them in the Android `strings.xml` file
Expand All @@ -32,6 +32,10 @@ This plugin requires the Vidinoti SDK version >= 6.4.0

## Release note

### Version 0.2.0 - 19 October 2022

Fix for Android 12

### Version 0.1.2 - 27 February 2020

Set firebase dependencies version
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-vidinoti-push",
"version": "0.1.2",
"version": "0.2.0",
"description": "Cordova Plugin for Vidinoti V-Director push integration",
"cordova": {
"id": "cordova-plugin-vidinoti-push",
Expand Down
10 changes: 2 additions & 8 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-vidinoti-push" version="0.1.2">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-vidinoti-push" version="0.2.0">
<name>Vidinoti Push</name>
<description>Cordova Plugin for Vidinoti V-Director push integration</description>
<license>MIT</license>
<keywords>cordova, augmented reality, vidinoti</keywords>

<platform name="android">

<source-file src="src/android/VidinotiInstanceIDListenerService.java" target-dir="src/com/vidinoti/cordova" />
<source-file src="src/android/VidinotiFcmListenerService.java" target-dir="src/com/vidinoti/cordova" />

<config-file parent="/resources" target="res/values/strings.xml">
Expand All @@ -18,16 +17,11 @@
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest/application">
<service android:name="com.vidinoti.cordova.VidinotiFcmListenerService">
<service android:name="com.vidinoti.cordova.VidinotiFcmListenerService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.vidinoti.cordova.VidinotiInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</config-file>

<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
Expand Down
15 changes: 13 additions & 2 deletions src/android/VidinotiFcmListenerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import android.content.pm.ApplicationInfo;
import android.media.RingtoneManager;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.vidinoti.android.vdarsdk.VDARSDKController;

import java.util.Map;

Expand Down Expand Up @@ -55,7 +57,7 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
appIntent.putExtra("nid", nid);
appIntent.putExtra("remote", true);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, appIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, appIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);

ApplicationInfo ai = getApplicationInfo();
createNotificationChannel(notificationManager);
Expand Down Expand Up @@ -87,4 +89,13 @@ private void createNotificationChannel(NotificationManager notificationManager)
notificationManager.createNotificationChannel(channel);
}
}

@Override
public void onNewToken(@NonNull String token) {
// Forward the token to the Vidinoti SDK
VDARSDKController controller = VDARSDKController.getInstance();
if (controller != null) {
controller.updatePushNotificationToken(token);
}
}
}
23 changes: 0 additions & 23 deletions src/android/VidinotiInstanceIDListenerService.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.gms:google-services:4.3.10'
}
}

0 comments on commit b2a1031

Please sign in to comment.