Skip to content

Commit

Permalink
RMET-2739 ::: Prepare Release 2.0.0 (#73)
Browse files Browse the repository at this point in the history
* chore: Add Unreleased Tag to CHANGELOG

* RMET-2036 :: Updated jcenter to mavenCentral (#40)

* RMET-2045 - Firebase Cloud Messaging Plugin - Use fixed versions (#39)

* fix: use fixed versions

References: https://outsystemsrd.atlassian.net/browse/RMET-2045

* chore: update changelog

* refactor: remove jcenter

References: https://outsystemsrd.atlassian.net/browse/RMET-2036

* chore: update changelog

* feat: iOS | Add Get APNs Token (#41)

Update iOS lib files in order to include the new Get APNs Token method.
Delegate the app's `application:didRegisterForRemoteNotificationWithDeviceToken:` to Cloud Messaging's delegate extension.

* RMET-2114 FB Cloud Messaging - Android - Fix click notification without deeplink (#42)

* tentativefix: added pending intent to every notification

* chore: update lib for testing

References: https://outsystemsrd.atlassian.net/browse/RMET-2114

* chore: update lib

* feat: update messaging library to version 1.0.1

References: https://outsystemsrd.atlassian.net/browse/RMET-2114

* refactor: remove new line

* chore: update changelog

Co-authored-by: Nelson Lopes Silva <5671236+nflsilva@users.noreply.github.com>

* Fix: Silent Notifications issue (#44)

The method `application:didReceiveRemoteNotification:fetchCompletionHandler:` is not being triggered by apps that use the plugin, so it's not possible to trigger silent notifications.
The same fix was applied for the `application:didRegisterForRemoteNotificationsWithDeviceToken:` as the method suffered from the same issue.

* fix: Replace iOS code for library (#45)

Remove the iOS code and replace it for the xcframework.

* RMET-2312 :: Empty silent notification crash fix (#46)

* chrore: bump patch version to 1.0.6. Changed lib version to new patch vesion 1.0.2

* chrore: bump patch version to 1.0.6

* feat: iOS | Use Local Notifications library (#48)

Update the iOS xcframework that already includes the Local Notifications library.
Add the local notifications library.
Remove unnecessary files introduced on conflict fix.

* RMET-2310 FB Cloud Messaging - Update FCM lib and add Local Notifications Lib (#49)

* feat: update osfirebasemessaging-android

References: https://outsystemsrd.atlassian.net/browse/RMET-2310

* fix: include local notifications lib in build.gradle

* chore: update changelog

* feat: React to "Push" Data Message (#51)

Update the OSFirebaseMessagingLib and OSLocalNotificationsLib in order to allow the trigger of Local Notifications when a Data Message with a Notification structure is received.

* RMET-2378 Cloud Messaging Plugin - Hook for sound files (#52)

* feat: first version of hook to copy sound files

References: https://outsystemsrd.atlassian.net/browse/RMET-2378

* chore: save current progress

* refactor: remove comment

* refactor: remove unnecessary code from hook

References: https://outsystemsrd.atlassian.net/browse/RMET-2378

* refactor: remove unnecessary functions

References: https://outsystemsrd.atlassian.net/browse/RMET-2378

* chore: update libs

References: https://outsystemsrd.atlassian.net/browse/RMET-2378

* chore: update changelog

* refactor: replace var with let

* refactor: replace var with let

* refactor: use let instead of var

* chore: update lib version

* RMET-2421 FCM Plugin  - Fix click notification crash (#53)

* chore: update lib version

* chore: update lib version

* chore: update lib

* chore: update changelog

* chore: update lib version

* chore: update lib versions

* feat: Add Actions to "Push" Data Messages (#55)

Update the OSFirebaseMessagingLib and OSLocalNotificationsLib to add reaction to a Push Data Message with Actions configured.

Co-authored-by: Marta Carlos <marta.carlos@outsystems.com>

* RMET-2387 FCM Plugin - Android - Add action buttons (#57)

* chore: update libs

* chore: update libs

* feat: handle action button clicks

References: https://outsystemsrd.atlassian.net/browse/RMET-2387

* chore: update changelog

* feat: iOS | Click on Notification Action (#56)

Update the OSFirebaseMessagingLib and OSLocalNotificationsLib to add reaction to a Notification Action click.

* Feat: iOS | React to the Internal Route Event (#58)

Update both OSFirebaseMessagingLib and OSLocalNotificationsLib to the latest versions.
Add "internalRouteActionClick" to the list of possible events can be triggered.

* RMET-2215 FCM Plugin - Fix on hook for sound files (#61)

* test: test build without hook

* test: include hook

* test: change hook name

* test: remove defer.promise

* chore: update changelog

* Feat: iOS | React to the Web Route Event (#60)

Update OSLocalNotificationLib.xcframework and OSFirebaseMessagingLib.xcframework to the latest versions so that it can deal with Actions defined with a web route event.

* current implementation (#62)

Add to plugin.xml a new hook that reads Extensibility Configurations' APPLICATION_SCHEMES preference value, and adds it to Info.plist's LSApplicationQueriesSchemes property.

* RMET-2391 FCM Plugin - Notification action buttons (#64)

* chore: update lib versions

* chore: update lib version

* chore: update lib version

* chore: update gradle dependency

* feat: iOS | React to the App Route Event (#63)

Update OSLocalNotificationLib.xcframework and OSFirebaseMessagingLib.xcframework to the latest versions so that it can deal with Actions defined with a app route event.

* RMET-2555 :: Update error codes (#65)

* feat: update error codes

* chore: update changelog

* chore: Set Tag and Update iOS libraries

Set tag on the `CHANGELOG.md` file.
Update `OSFirebaseMessagingLib.xcframework` and `OSLocalNotificationsLib.xcframework` to the latest versions.

* chore: set missing Tags

Set Tags to `package.json` and `plugin.xml` files.

* chore: use correct OSFirebaseMessagingLib.xcframework

* chore: update android libraries

* feat: update firebase-core version (#67)

* RMET-2464 :: account for sound zip (#68)

* feat: update hook to unzip files

* RMET-2464 :: one file unzipping (#69)

* feat: update hook to unzip files

* fix: add case for zip with only one file

* fix: remove zip file and folder

* fix: typo

* fix: add recursive delete

* refactor: to follow CR advice

* RMET-2695 :: fix hook execution (#70)

* fix: change hook execution

* remove changelog entry + use remove deprecated function

* feat: add case for zip of sounds folder instead of just files

* feat: add verification of sound file to better abstract where it should be saved

* deleting unnecessary files

* refactor

* try: removing the deletion of zip file

* fix: iOS | Trigger "NotificationClickV2" (#71)

Update the iOS library to use the latest version that enables the correct triggering of the new NotificationClick event.
Update the implementation of the "FirebaseMessagingEventProtocol" to trigger multiple events simultaneously, including the new NotificationClick event.
Extend OSFCMClickableType and FirebaseNotificationType to implement the CustomStringConvertible protocol, applying the correct value to the description property.

* fix: typo in internalRouteActionClick

* chore: Raise Tag Version (#72)

Raise tag version to "2.0.0".
Update iOS and Android libraries to the latest versions.

* fix: unzip sound file

* fix: last commit

* fix: add project root to destination folder when unzipping

* chore: raise adm zip version bc snyk

---------

Co-authored-by: Alexandre Jacinto <alexandre.jacinto@outsystems.com>
Co-authored-by: Nelson Lopes Silva <5671236+nflsilva@users.noreply.github.com>
Co-authored-by: Marta Carlos <marta.carlos@outsystems.com>
Co-authored-by: Marta Carlos <101343976+OS-martacarlos@users.noreply.github.com>
  • Loading branch information
5 people committed Aug 10, 2023
1 parent f3aeb18 commit 9ea4058
Show file tree
Hide file tree
Showing 33 changed files with 20,825 additions and 166 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

## [Version 2.0.0]
- Feat: update sound hook to unzip sound files, for both iOS and Android (https://outsystemsrd.atlassian.net/browse/RMET-2464).
- Feat: update firebase core version (https://outsystemsrd.atlassian.net/browse/RMET-2451).

## [Version 1.2.0]

### 23-05-2023
Expand Down
33 changes: 33 additions & 0 deletions hooks/cleanUp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";

var path = require("path");
var utils = require("./utilities");

var constants = {
soundFolder: "/sounds"
};

module.exports = function(context) {
let cordovaAbove8 = utils.isCordovaAbove(context, 8);
let defer;
if (cordovaAbove8) {
defer = require("q").defer();
} else {
defer = context.requireCordovaModule("q").defer();
}

let platform = context.opts.platforms[0];
let platformConfig = utils.getPlatformConfigs(platform);

if (!platformConfig) {
utils.handleError("Invalid platform", defer);
}

let sourcePath = utils.getPlatformSoundPath(context, platformConfig)
let soundFolderPath = path.join(sourcePath, constants.soundFolder);

if(utils.checkIfFileOrFolderExists(soundFolderPath)){
utils.removeFolder(soundFolderPath);
}

}
82 changes: 82 additions & 0 deletions hooks/unzipSound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"use strict";

let path = require("path");
let utils = require("./utilities");
let AdmZip = require("adm-zip");

let constants = {
soundZipFile: "sounds.zip"
};

function copyWavFiles(platformConfig, source, dest, defer) {
let files = utils.getFilesFromPath(source);

let filteredFiles = files.filter(function(file){
return file.endsWith(platformConfig.soundFileExtension) == true;
});

copyFiles(filteredFiles, source, dest, defer)
}

function copyFiles(files, source, dest, defer){
if(!files){
utils.handleError("Something went wrong when trying to unzip sounds.zip, no files were found", defer);
return
}

if(!utils.checkIfFileOrFolderExists(dest)) {
utils.createOrCheckIfFolderExists(dest);
}

for(const element of files) {
let filePath = path.join(source, element);
let destFilePath = path.join(dest, element);
utils.copyFromSourceToDestPath(defer, filePath, destFilePath);
}
}

module.exports = function(context) {
let cordovaAbove8 = utils.isCordovaAbove(context, 8);
let defer;
if (cordovaAbove8) {
defer = require("q").defer();
} else {
defer = context.requireCordovaModule("q").defer();
}

let platform = context.opts.platforms[0];
let platformConfig = utils.getPlatformConfigs(platform);
if (!platformConfig) {
utils.handleError("Invalid platform", defer);
}

let sourcePath = utils.getPlatformSoundPath(context, platformConfig)
let soundFolderPath = platformConfig.getSoundDestinationFolder();
soundFolderPath = path.join(context.opts.projectRoot, soundFolderPath);

let soundZipFile = path.join(sourcePath, constants.soundZipFile);

if(utils.checkIfFileOrFolderExists(soundZipFile)){
let zip = new AdmZip(soundZipFile);
zip.extractAllTo(sourcePath, true);

let entriesNr = zip.getEntries().length;

if(entriesNr == 0) {
utils.handleError("Sound zip file is empty, either delete it or add one or more files", defer);
return
}

let zipFolder = sourcePath + "/sounds"

if(!utils.checkIfFileOrFolderExists(zipFolder)){
/**to deal with the following case:
* iOS + one file in zip + O11
**/
if(sourcePath != soundFolderPath)
copyWavFiles(platformConfig, sourcePath, soundFolderPath, defer)
} else {
copyWavFiles(platformConfig, zipFolder, soundFolderPath, defer)
}
}
}
127 changes: 127 additions & 0 deletions hooks/utilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"use strict"

var path = require("path");
var fs = require("fs");

var constants = {
platforms: "platforms",
android: {
platform: "android",
wwwFolder: "www",
soundFileExtension: ".wav",
getSoundDestinationFolder: function() {
return "platforms/android/app/src/main/res/raw";
},
getWWWFolder: function() {
return "www";
}
},
ios: {
platform: "ios",
wwwFolder: "www",
soundFileExtension: ".wav",
getSoundDestinationFolder: function() {
return "platforms/ios/www";
},
getWWWFolder: function() {
return "platforms/ios/www";
}
}
};

function handleError(errorMessage, defer) {
console.log(errorMessage);
defer.reject();
}


function checkIfFileOrFolderExists(path) {
return fs.existsSync(path);
}

function removeFile(path){
fs.unlinkSync(path)
}

function removeFolder(path){
fs.rmSync(path, { recursive: true })
}

function getFilesFromPath(path) {
return fs.readdirSync(path);
}

function createOrCheckIfFolderExists(path) {
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
}

function getPlatformConfigs(platform) {
if (platform === constants.android.platform) {
return constants.android;
} else if (platform === constants.ios.platform) {
return constants.ios;
}
}

function getPlatformSoundPath(context, platformConfig){
let projectRoot = context.opts.projectRoot;
let platformPath;

if(platformConfig === constants.android){
platformPath = path.join(projectRoot, `platforms/android/www`);
} else {
let appName = getAppName(context)
platformPath = path.join(projectRoot, `platforms/ios/${appName}/Resources/www`);
}

if(!fs.existsSync(platformPath)){
platformPath = path.join(projectRoot, platformConfig.getWWWFolder());
}

return platformPath
}

function isCordovaAbove(context, version) {
let cordovaVersion = context.opts.cordova.version;
let sp = cordovaVersion.split('.');
return parseInt(sp[0]) >= version;
}


function copyFromSourceToDestPath(defer, sourcePath, destPath) {
fs.createReadStream(sourcePath).pipe(fs.createWriteStream(destPath))
.on("close", function (err) {
defer.resolve();
})
.on("error", function (err) {
console.log(err);
defer.reject();
});
}

function isAndroid(platform){
return platform === constants.android.platform
}

function getAppName(context) {
let ConfigParser = context.requireCordovaModule("cordova-lib").configparser;
let config = new ConfigParser("config.xml");
return config.name();
}

module.exports = {
isCordovaAbove,
handleError,
getPlatformConfigs,
copyFromSourceToDestPath,
getFilesFromPath,
createOrCheckIfFolderExists,
checkIfFileOrFolderExists,
removeFile,
removeFolder,
isAndroid,
getAppName,
getPlatformSoundPath
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.outsystems.firebase.cloudmessaging",
"version": "1.2.0",
"version": "2.0.0",
"description": "Outsystems plugin for Firebase Cloud Messaging",
"keywords": [
"ecosystem:cordova",
Expand All @@ -14,5 +14,8 @@
"android"
]
},
"engines": []
"engines": [],
"dependencies": {
"adm-zip": "0.5.2"
}
}
11 changes: 6 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin id="com.outsystems.firebase.cloudmessaging" version="1.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.outsystems.firebase.cloudmessaging" version="2.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>OSFirebaseCloudMessaging</name>
<description>Outsystems plugin for Firebase Cloud Messaging</description>
<author>OutSystems Inc</author>
<js-module name="OSFirebaseCloudMessaging" src="www/OSFirebaseCloudMessaging.js">
<clobbers target="cordova.plugins.OSFirebaseCloudMessaging"/>
</js-module>

<dependency id="cordova-outsystems-firebase-core" url="https://github.com/OutSystems/cordova-outsystems-firebase-core.git#1.0.0"/>
<dependency id="cordova-outsystems-firebase-core" url="https://github.com/OutSystems/cordova-outsystems-firebase-core.git#2.0.0"/>

<hook type="after_prepare" src="hooks/unzipSound.js" />
<hook type="after_prepare" src="hooks/cleanUp.js" />

<platform name="ios">

<config-file parent="/*" target="config.xml">
Expand All @@ -34,6 +37,7 @@
</config-file>

<!-- iOS Source Files -->
<source-file src="src/ios/OSFCMEventExtensions.swift" />
<source-file src="src/ios/OSFirebaseCloudMessaging.swift" />
<header-file src="src/ios/AppDelegate+OSFirebaseCloudMessaging.h" />
<source-file src="src/ios/AppDelegate+OSFirebaseCloudMessaging.m" />
Expand Down Expand Up @@ -61,9 +65,6 @@
<platform name="android">

<hook type="after_prepare" src="hooks/android/androidCopyChannelInfo.js" />

<hook type="before_plugin_install" src="hooks/android/sound/copySound.js" />

<config-file parent="/*" target="res/xml/config.xml">
<feature name="OSFirebaseCloudMessaging">
<param name="android-package" value="com.outsystems.firebase.cloudmessaging.OSFirebaseCloudMessaging"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'kotlin-kapt'
dependencies {
implementation("com.github.outsystems:oscore-android:1.2.0@aar")
implementation("com.github.outsystems:oscordova-android:1.2.0@aar")
implementation("com.github.outsystems:osfirebasemessaging-android:1.1.0@aar")
implementation("com.github.outsystems:osfirebasemessaging-android:1.1.3@aar")
implementation("com.github.outsystems:oslocalnotifications-android:1.0.0@aar")
implementation("com.github.outsystems:osnotificationpermissions-android:0.0.4@aar")

Expand Down
24 changes: 24 additions & 0 deletions src/ios/OSFCMEventExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import OSFirebaseMessagingLib

extension OSFCMClickableType: CustomStringConvertible {
public var description: String {
var result: String
switch self {
case .notification(latestVersion: let latestVersion):
result = "notificationClick"
if latestVersion {
result += "V2"
}
case .action:
result = "internalRouteActionClick"
@unknown default:
preconditionFailure("Not supposed to get here")
}

return result
}
}

extension FirebaseNotificationType: CustomStringConvertible {
public var description: String { "\(self == .silentNotification ? "silent": "default")Notification" }
}
6 changes: 4 additions & 2 deletions src/ios/OSFirebaseCloudMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ extension OSFirebaseCloudMessaging: FirebaseMessagingEventProtocol {

switch event {
case .click(type: let type):
eventName = type == .notification ? "notificationClick" : "internalRouteActionClick"
eventName = type.description
case .trigger(notification: let notification):
eventName = notification == .silentNotification ? "silentNotification" : "defaultNotification"
eventName = notification.description
@unknown default:
preconditionFailure("Not supposed to get here")
}

self.trigger(event: eventName, data: data)
Expand Down
10 changes: 5 additions & 5 deletions src/ios/frameworks/OSFirebaseMessagingLib.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>OSFirebaseMessagingLib.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>OSFirebaseMessagingLib.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Loading

0 comments on commit 9ea4058

Please sign in to comment.