Skip to content

Commit

Permalink
RMET-3236 :: Merge development into main (#52)
Browse files Browse the repository at this point in the history
* chore: Add Unreleased Tag to CHANGELOG

* fix: Optional Apple SignIn (#36)

Apply fix on hook that checks if Apple SignIn should be included on the plugin or not. This is done by changing the Debug and Release Entitlements files.

* RMET-2252 :: Remove JSON file dependency , add Endpoint (#38)

* feat: add endpoint logic to android hook

* fix: add config parser import

* removing fetch + add axios

* minor typo fix

* feat: add get endpoint to iOS

* remove static dependency

* adding more error handling

* chore: refactor

* refactor: rename preference to be more accurate

* reactor: change preference according to Dev Exp suggestion

* fix: change error accordingly

* feat: iOS | Update Error Codes (#40)

Update error codes.
Update library to use new error descriptions.
Delete console logs from hook.

* RMET-2343 Social Logins Plugin - Update error codes (#39)

* feat: format error codes

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

* chore: update changelog

* fix: fixing typo on error message

---------

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

* chore: Set Release Tag

Set Release Tag and update Android and iOS libraries to the latest ones.

* RMET-2844 ::: Android ::: Facebook fix for MABS 10 (#43)

* fix: updated facebook-android-sdk version for MABS10 bug.

* fix: added sociallogins lib 1.1.1-r1

* chore: updated changelog

* chore: bumped version to 1.1.2

* fix: Deep Link Issue (#45)

Fix issue with the deep link, where the plugin would replace all `URLScheme`'s with the ones expected by the plugin.

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

* chore: prepare for release (#46)

- updates package version
- updates changelog
- updates plugin.xml

https://outsystemsrd.atlassian.net/browse/RMET-3064

* fix: Deep Link to Specific Screen Issue (#48)

Fix the issue with the deep link, where the plugin would not delegate the `ApplicationID` deep link to `CDVAppDelegate`, not making the expected route to the desired screen.

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

* RMET-2800 ::: iOS ::: Add new `GIDClientID` Property (#49)

* chore: New Google Client ID for iOS library

Update 'OSSocialLoginsLib.xcframework' to the latest version. For Google Sign-in, this requires a new property for the 'Info.plist' file: 'GIDClientID'. This is set, if configured, through the 'iOSCopyPreference' hook, based on the Google URL Scheme value.
Do some refactoring to the 'iOSCopyPreferences' hook and 'plugin.xml', removing redundant code and unneeded placeholders.

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

* chore: Add CHANGELOG entry

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

* feat: raise iOS lib (#51)

- adds the new version of iOS' lib which raises Google and Facebook dependencies versions
- updates changelog and packagejson

https://outsystemsrd.atlassian.net/browse/RMET-3236

---------

Co-authored-by: OS-ricardomoreirasilva <ricardo.moreira.silva@outsystems.com>
Co-authored-by: Ricardo Silva <97543217+OS-ricardomoreirasilva@users.noreply.github.com>
Co-authored-by: Alexandre Jacinto <alexandre.jacinto@outsystems.com>
Co-authored-by: Nelson Lopes da Silva <5671236+nflsilva@users.noreply.github.com>
  • Loading branch information
5 people committed Mar 22, 2024
1 parent 303dc2e commit fc629d5
Show file tree
Hide file tree
Showing 25 changed files with 11,175 additions and 105 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ 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.3 (2024-03-21)

### 2024-02-29
- Chore: [iOS] Set the new `GIDClientID` property for `plist` file. This is required for `Google Sign-In` version `7.0.0` (https://outsystemsrd.atlassian.net/browse/RMET-2800).

### 2024-01-30
- Fix: [iOS] Unable for an app to route into the screen mentioned in the deep link (using the `ApplicationID`). (https://outsystemsrd.atlassian.net/browse/RMET-3139)

## Version 2.0.2 (2024-01-23)

### 2024-01-22
- Fix: [iOS] Unable to use `Application ID` as `URL Scheme` when the plugin is installed.
- Fix: [iOS] Unable to use `Application ID` as `URL Scheme` when the plugin is installed. (https://outsystemsrd.atlassian.net/browse/RMET-3063)

## Version 2.0.1 (2023-10-24)

Expand Down
74 changes: 49 additions & 25 deletions hooks/iOSCopyPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@ const { Console } = require('console');

const {getJsonFile, ProvidersEnum, ApplicationTypeEnum} = require('./utils');

function reverseURLScheme(str) {
// Step 1. Use the split() method to return a new array
var splitString = str.split("."); // split "hello.world"
// ["hello", "world"]

// Step 2. Use the reverse() method to reverse the new created array
var reverseArray = splitString.reverse(); // reverse ["hello", "world"]
// ["world", "hello"]

// Step 3. Use the join() method to join all elements of the array into a string
var joinArray = reverseArray.join("."); // join ["world", "hello"]
// "world.hello"

//Step 4. Return the reversed string
return joinArray;
}

module.exports = async function (context) {
var projectRoot = context.opts.cordova.project ? context.opts.cordova.project.root : context.opts.projectRoot;

var google_url_scheme = "";
var google_client_id = "";

var facebook_client_appId = "";
var facebook_client_token = "";
Expand Down Expand Up @@ -40,6 +58,7 @@ module.exports = async function (context) {

if (configItem.url_scheme != null && configItem.url_scheme !== "") {
google_url_scheme = configItem.url_scheme;
google_client_id = reverseURLScheme(google_url_scheme);
} else {
googleErrorArray.push('URL Scheme');
}
Expand Down Expand Up @@ -92,38 +111,43 @@ module.exports = async function (context) {
var infoPlistFile = fs.readFileSync(infoPlistPath, 'utf8');
var infoPlist = plist.parse(infoPlistFile);

const initialCFBundleURLTypeArray = infoPlist['CFBundleURLTypes'];
var finalCFBundleURLTypeArray = [];
initialCFBundleURLTypeArray.forEach(function(item) {
if (item['CFBundleURLName'] == 'Google') {
if (google_url_scheme != '') {
item['CFBundleURLSchemes'] = [google_url_scheme];
finalCFBundleURLTypeArray.push(item);
}
} else if (item['CFBundleURLName'] == 'Facebook') {
if (facebook_client_appId != '') {
item['CFBundleURLSchemes'] = ['fb' + facebook_client_appId];
finalCFBundleURLTypeArray.push(item);
}
} else if (item['CFBundleURLName'] == 'DeepLinkScheme') {
item['CFBundleURLSchemes'] = [deeplink_url_scheme];
finalCFBundleURLTypeArray.push(item);
} else {
finalCFBundleURLTypeArray.push(item);
}
});
infoPlist['CFBundleURLTypes'] = finalCFBundleURLTypeArray;
var cfbundleURLTypeArray = infoPlist['CFBundleURLTypes'];

const deepLinkSchemeHashMap = {
'CFBundleURLName': 'DeepLinkScheme',
'CFBundleURLSchemes': [deeplink_url_scheme]
};
cfbundleURLTypeArray.push(deepLinkSchemeHashMap);

if (google_url_scheme != '') {
const googleURLSchemeHashMap = {
'CFBundleURLName': 'Google',
'CFBundleURLSchemes': [google_url_scheme]
};

cfbundleURLTypeArray.push(googleURLSchemeHashMap);
}

if (facebook_client_appId != '') {
const facebookClientAppIdHashMap = {
'CFBundleURLName': 'Facebook',
'CFBundleURLSchemes': ['fb' + facebook_client_appId]
};

cfbundleURLTypeArray.push(facebookClientAppIdHashMap);
}
infoPlist['CFBundleURLTypes'] = cfbundleURLTypeArray;

if (facebook_client_appId != '') {
infoPlist['FacebookAppID'] = facebook_client_appId
} else {
delete infoPlist['FacebookAppID'];
}

if (facebook_client_token != '') {
infoPlist['FacebookClientToken'] = facebook_client_token;
} else {
delete infoPlist['FacebookClientToken'];
}

if (google_client_id != '') {
infoPlist['GIDClientID'] = google_client_id;
}

fs.writeFileSync(infoPlistPath, plist.build(infoPlist, { indent: '\t' }));
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": "com.outsystems.plugins.sociallogins",
"version": "2.0.2",
"version": "2.0.3",
"description": "OutSystems Template for Cordova Plugin",
"keywords": [
"ecosystem:cordova",
Expand Down
41 changes: 1 addition & 40 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin id="com.outsystems.plugins.sociallogins" version="2.0.2" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.outsystems.plugins.sociallogins" version="2.0.3" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>OSSocialLogins</name>
<description>OutSystems Template for Cordova Plugin</description>
<author>OutSystems Inc</author>
Expand Down Expand Up @@ -74,45 +74,6 @@
<preference name="UseSwiftLanguageVersion" value="5" />
</config-file>

<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>Google</string>
<key>CFBundleURLSchemes</key>
<array>
<string>GOOGLE_CLIENT_ID</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>Facebook</string>
<key>CFBundleURLSchemes</key>
<array>
<string>FACEBOOK_CLIENT_URLSCHEME</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>DeepLinkScheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>DEEP_LINK_URLSCHEME</string>
</array>
</dict>
</array>
</config-file>

<config-file target="*-Info.plist" parent="FacebookAppID">
<string>FACEBOOK_CLIENT_APPID</string>
</config-file>

<config-file target="*-Info.plist" parent="FacebookClientToken">
<string>FACEBOOK_CLIENT_TOKEN</string>
</config-file>

<config-file target="*-Info.plist" parent="LSApplicationQueriesSchemes">
<array>
<string>fbapi</string>
Expand Down
27 changes: 22 additions & 5 deletions src/ios/AppDelegate+OSSocialLogins.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,27 @@ - (BOOL)application:(UIApplication *)application socialLoginsPluginDidFinishLaun
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [SocialLoginsApplicationDelegate.shared
application:app
openURL:url
options:options];
// gets the passed url's `urlScheme`
NSString *currentUrlScheme = [url.absoluteString componentsSeparatedByString:@"://"].firstObject;

// check if it should delegate to the library or to `CDVAppDelegate`
return [self shouldDelegateToLibrary:currentUrlScheme] ? [SocialLoginsApplicationDelegate.shared application:app openURL:url options:options] : [super application:app openURL:url options:options];
}

- (BOOL)shouldDelegateToLibrary:(NSString *)openURLScheme {
// fetch all app's `utlTypes`
NSArray *urlTypes = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"];
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary<NSString *,id> * bindings) {
// fetch the `urlSchemes` associated to the evaluated `urlType`
NSArray * urlSchemeArray = evaluatedObject[@"CFBundleURLSchemes"];
// verifies if the `urlType` relates with the `urlScheme` of the to-be-opened URL
return [urlSchemeArray containsObject:openURLScheme];
}];

// applying the filter, it fetches the `urlName` of the matching `urlType`
NSString *urlName = [urlTypes filteredArrayUsingPredicate:predicate].firstObject[@"CFBundleURLName"];
// checks if the matching `urlName` is one that can be delegated to the library.
return [@[@"Google", @"Facebook", @"DeepLinkScheme"] containsObject:urlName];
}

@end
@end
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Generated by Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
#ifndef OSSOCIALLOGINSLIB_SWIFT_H
#define OSSOCIALLOGINSLIB_SWIFT_H
#pragma clang diagnostic push
Expand All @@ -21,11 +23,20 @@
# include <swift/objc-prologue.h>
#endif

#pragma clang diagnostic ignored "-Wduplicate-method-match"
#pragma clang diagnostic ignored "-Wauto-import"
#if defined(__OBJC__)
#include <Foundation/Foundation.h>
#endif
#if defined(__cplusplus)
#include <cstdint>
#include <cstddef>
#include <cstdbool>
#else
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#endif

#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
Expand Down Expand Up @@ -181,16 +192,40 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#else
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
#endif
#if defined(__OBJC__)
#if !defined(IBSegueAction)
# define IBSegueAction
#endif
#endif
#if !defined(SWIFT_EXTERN)
# if defined(__cplusplus)
# define SWIFT_EXTERN extern "C"
# else
# define SWIFT_EXTERN extern
# endif
#endif
#if !defined(SWIFT_CALL)
# define SWIFT_CALL __attribute__((swiftcall))
#endif
#if defined(__cplusplus)
#if !defined(SWIFT_NOEXCEPT)
# define SWIFT_NOEXCEPT noexcept
#endif
#else
#if !defined(SWIFT_NOEXCEPT)
# define SWIFT_NOEXCEPT
#endif
#endif
#if defined(__cplusplus)
#if !defined(SWIFT_CXX_INT_DEFINED)
#define SWIFT_CXX_INT_DEFINED
namespace swift {
using Int = ptrdiff_t;
using UInt = size_t;
}
#endif
#endif
#if defined(__OBJC__)
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
Expand All @@ -201,13 +236,15 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
@import UIKit;
#endif

#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
#endif
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wnullability"
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"

#if __has_attribute(external_source_symbol)
# pragma push_macro("any")
Expand All @@ -216,6 +253,7 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
# pragma pop_macro("any")
#endif

#if defined(__OBJC__)



Expand Down Expand Up @@ -280,8 +318,15 @@ SWIFT_CLASS("_TtC17OSSocialLoginsLib30SocialLoginsLinkedInController")
@end


#endif
#if defined(__cplusplus)
#endif
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop
#endif

#else
#error unsupported Swift architecture
#endif
Binary file not shown.
Loading

0 comments on commit fc629d5

Please sign in to comment.