Open PhilippS93 opened 4 years ago
I got the same error after clean install. Been able to get rid of it by removing nativescript-plugin-firebase pacakge and platforms catalog. I can't find the way for those two packages to work together yet. Аlthough it worked before I decided to reinstall packages.
My solution was to retry creation of TnsOAuthClient. It fails with this error on first attempt, but always works on second attempt.
get oAuthClient() {
if (!this._oAuthClient) {
try {
this._oAuthClient = new TnsOAuthClient('identityServer', true);
} catch (e) {
console.error('Failed to create TnsOAuthClient. Retry...', e);
this._oAuthClient = new TnsOAuthClient('identityServer', true);
}
}
return this._oAuthClient;
}
I was setting up a new environment this afternoon and ran into the same error. Here's some additional info I've found along the way:
Omitting the firebase plugin always solved the problem, but that's not great. Using both plugins with tns-ios 6.4.x or 6.5.x resulted in an error, but tns-ios 6.3.0 worked for both plugins
Having the same issue:
nativescript-oauth2/tns-oauth-native-view-controller.ios.js:12:23: JS ERROR Error: Class "SFSafariViewController" referenced by type encoding not found at runtime. (evaluating 'new TnsOAuthLoginNativeViewController()')
Currently on Nativescript 6.5.0 for both platforms with a Nativescript-Vue application.
My conflict is with the nativescript-urban-airship plugin but this issues has seemed to arise with other developers who are seeking to integrate push notifications into their application.
NOTE: Downgrading to Nativescript 6.3.0
does work as a temporary workaround as @dscirto mentioned.
Looks like newer version of NS are soon to be released. Hopefully this bug is accounted for in those upcoming releeases.
Hello together, I am seeing exactly the same issue when using the plugin together with nativescript-plugin-firebase and I tried with NS 6.5.0 and NS 6.5.1. I debugged the issue in the plugin down to the following file
the new fails
const instance = new TnsOAuthLoginNativeViewController();
as the SFSafariViewController seems to be unknown. The thing I do not understand here is that the class SFSafariViewController is not imported and that I have not found a nativescript module yet which exports it. Some Nativescript magic on how to use native objects? If someone could tell the correct import it would be great if he mentions it here, as I had to fork the sources due to other topics and would like to get rid of this workaround. Note, what is even more weird to my understanding is, that calling new twice, leads to the previously mentioned behavior. The second call succeeds. Hence, the following code is a workaround that does the job for me. However, it is not clear why it works and is not a real solution. Would be great if someone could help on the topic
Here the workaround:
public static initWithClient(client: TnsOAuthClient) {
// create view controller instance
let instance = TnsOAuthLoginNativeViewController.createInstance(client);
if (!instance) {
instance = TnsOAuthLoginNativeViewController.createInstance(client);
}
return instance;
}
private static createInstance(client: TnsOAuthClient) {
let instance: TnsOAuthLoginNativeViewController;
try {
instance = new TnsOAuthLoginNativeViewController();
if (instance) {
instance.loginController = new TnsOAuthLoginSubController(client);
// get style options
if (client.provider.styleOptions) {
instance.styleOptions = client.provider.styleOptions;
}
}
} catch (e) {
console.log(e);
}
return instance;
}
The issue can be closed, see here: https://github.com/alexziskind1/nativescript-oauth2/issues/135
Make sure to check the demo app(s) for sample usage
Make sure to check the existing issues in this repository
If the demo apps cannot help and there is no issue for your problem, tell us about it
Please, ensure your title is less than 63 characters long and starts with a capital letter.
Which platform(s) does your issue occur on?
iOS/Android/Both Android
iOS/Android versions iOS 13
emulator or device. What type of device? device
Please, provide the following version numbers that your issue occurs with:
CLI: (run
tns --version
to fetch it) 6.5.0Cross-platform modules: (check the 'version' attribute in the
node_modules/tns-core-modules/package.json
file in your project) 6.5.1Runtime(s): (look for the
"tns-android"
and"tns-ios"
properties in thepackage.json
file of your project)Plugin(s): (look for the version numbers in the
package.json
file of your project and paste your dependencies and devDependencies here) "nativescript-oauth2": "^2.4.0",Please, tell us how to recreate the issue in as much detail as possible.
Describe the steps to reproduce it.
When implementing the default google sing in process following the video LINK I get the following error when calling loginWithCompletion on iOS:
ERROR Error: Class "SFSafariViewController" referenced by type encoding not found at runtime. (evaluating 'new TnsOAuthLoginNativeViewController()')
Is there any code involved?
` @Injectable() export class OauthService {
} `