Cannot find name 'SFAuthSession' - ionic4

I am new to ionic and cordova plugins and I'm trying to implement the sharing of cookies using the cordova-plugin-sfauthenticationsession in my ionic app.
Here is my code based on the documentation provided in this link:
SFAuthSession.start("myScheme://","https://www.facebook.com/",
function(data){
console.log(data);
},function(error){
console.log(error);
}
);
The problem is whenever I try to build my app, the terminal shows an error that it cannot find SFAuthSession. I don't have any idea what I need to import (if any) since it is not included in the documentation. Hope somebody can help me with this.
P.S.
I also tried the safari view controller following this documentation and it is working fine since it provides what is to be imported.

This is a common error. The docs tell you how to install that specific plugin but they don't tell you that you also need to update your module file to include it.
Look at this page:
Ionic Native Community Edition - Ionic Documentation
It explains that you need to import the plugin in a #NgModule and add it to the list of Providers. For Angular, the import path should end with /ngx. Angular's change detection is automatically handled.
To do this you do:
// app.module.ts
import { Camera } from '#ionic-native/camera/ngx';
...
#NgModule({
...
providers: [
...
Camera
...
]
...
})
export class AppModule { }
So just import your Ionic Native module using that technique and you it should work.
When there is no Ionic Native wrapper
However, based on your comments below it is now clear that there isn't an Ionic Native wrapper for this Cordova plugin.
This means that you will have to either:
Access it without Ionic Native
OR write your own Ionic Native wrapper
It seems like this article on Medium has a great introduction to this:
Build your first Cordova plugin for Ionic Native – Sangkhim Khun – Medium
You have passed beyond my personal experience here but I'm trying to figure it out with you.
Part three of the tutorial has an interesting snippet for accessing a Cordova plugin directly:
declare var cordova: any;
var success = function(result) {
alert(JSON.stringify(result, undefined, 2));
}
var failure = function(result) {
alert(JSON.stringify(result, undefined, 2));
}
cordova.plugins.HelloWorld.coolMethod({
_sMessage: "Hello World"
}, success, failure);
You would have to compare the documentation of your Cordova plugin to adapt this yourself to get it working.
Alternatively, if you continue reading that tutorial it explains how to create an Ionic Native wrapper which you could even contribute back to the project so that everyone can use this feature.

Related

How to use nuxtjs/auth-next module with Nuxt3?

Just trying to add authentication to my NuxtJs 3 app folloging nuxt/auth configuration docs, but still get an error during app start:
// nuxt.config.js
export default defineNuxtConfig({
auth: {
// ...
},
modules: [
// '#nuxtjs/axios',
'#nuxtjs/auth-next'
],
})
Received same error for #nuxtjs/axios but I just commented it out since its official documentation indicates to switch to $fetch API.
Cannot figure out where the error is
nuxt-auth is not compatible with Nuxt3 as told here: https://github.com/nuxt-community/auth-module/issues/1805#issuecomment-1326287711
It's on the official roadmap but still not done by the core team.
You could google for a homemade solution online. Thanks to Nuxt3 composables and some logic, it is totally achievable without an official module.
You can use that community one in the meantime, as confirmed here.
At the time being, nuxt/auth module is not supported by Nuxt3.
You can find the list of modules supported by Nuxt3 here https://nuxt.com/modules?version=3.x
You can use this nuxt-auth module which is compatible with nuxt 3: https://nuxt.com/modules/nuxt-auth https://github.com/sidebase/nuxt-auth

Cannot integrate React Native Web with react Navigation

I am experiencing a lot of difficulties integrating React navigation in a React native WEB project.
I have created a mini project with react native web and react navigation in a cloud sandbox, everything works as expected.
Please have a look, I am not using the latest react navigation but I have tried previously the latest(updating the code as the API changed) and it works fine.
React Native web Running in Sandbox
I have cloned this project exactly as it is, installed all the dependencies and tried different versions of React Native Web, Webpack(version 3 and 4), babel(version 6 and 7) and the latest React Navigation (version 3+). I was not able to make it run on localhost, the error is:
Module parse failed: Unexpected token (10:22)
You may need an appropriate loader to handle this file type.
|
| class TabView extends React.PureComponent {
| static defaultProps = {
| lazy: true,
| removedClippedSubviews: true,
on React Navigation version 1.5.8 and a similar error on The latest version. But it works fine in the Sandbox.
Is anybody familiar with this type of setup and why the exact same code does not work on localhost?
I have tried also creating a webpack.config.js in the root and change configurations as some suggested but no luck.
You can clone this repo which is exactly the same sandbox and see for yourself.
Clone this Github Repo
Please any help would be greatly appreciated
This happened to me as well. The reason is because some of the modules provided by React Navigation are not transpiled to their corresponding react-native-web equivalent. What I mean is you need to transpile those modules individually using babel-loader or whatever you are using. Something like below in webpack.config or .babelrc should work:
{
test: /\.(js|jsx)$/,
include: [
path.resolve(root, "node_modules/#react-navigation"),
path.resolve(root, "node_modules/react-navigation"),
path.resolve(root, 'node_modules/react-native-uncompiled'),
path.resolve(root, "node_modules/react-native-tab-view"),
path.resolve(root, "node_modules/react-native-gesture-handler"),
path.resolve(root, "node_modules/react-native-vector-icons"),
path.resolve(root, "node_modules/react-native-web"),
path.resolve(root, "node_modules/react-native-tab-view"),
path.resolve(root, "node_modules/react-native-drawer"),
....and whatever module gives problem....
] // external non react-native packages to be compiled by Babel
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
plugins: ['react-native-web']
...
}
}
};
Here is an article with clear explanation on this topic: https://pickering.org/using-react-native-react-native-web-and-react-navigation-in-a-single-project-cfd4bcca16d0

IBM Mobilefirst V8 - Custom Direct update on hybrid application using Ionic v3.20.0 is not happening

I am trying to implement customized direct update in ionic v3.20.0 but while accessing to the below code, am unable to proceed. I can't find any way to do it as the below function is not there in worklight.d.ts file,but can be found at worklight.js file.
The plugin used is cordova-plugin-mfp. The solution provided in the official doc is relevant to only cordova application,that can be done through index.js file which has the function WlCommonInit(). As per the doc the below code is to be called from this function, but unable to do this in ionic-cordova based application.
wl_DirectUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData, directUpdateContext) {
// Implement custom Direct Update logic
};
Pleas refer to the below link for further information.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/direct-update/
Please help me to implement this in ionic v3.20.0 which need to be implemented in typescript. Thanks!.
Presently there is no typescript API for wl_DirectUpdateChallengeHandler in cordova-plugin-mfp to customize direct update in Ionic Applications.
However you can do implementation in the JavaScript and include it in the Ionic Project. Following are the steps :
Create a folder called js inside the path src/assets of the project
Create a new JS file with following code and save it as wldirectudpate.js
function wlCommonInit() {
console.log(">> wlCommonInit() ..." );
wl_DirectUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData, directUpdateContext) {
// Implement custom Direct Update logic
};
};
Add the JS location in index.html file which is located at /src/index.html
<script src="assets/js/wldirectudpate.js"></script>

Is it worth to migrate from Angular 2 to Angular 4?

Hello SO community and Angularians!
So, I am midway developing a huge platform in Angular 2. And I realized that many external libraries and dependencies for Angular 2 are migrating to the new Angular 4. Giving me many errors, obviously.
I could fork these libraries and use the forked versions and subscribe to main library development or, I could just upgrade to Angular 4 my project.
Questions to be answered in order to determinate if it's worth for me to migrate:
Compatibility with Angular 2.4
I have found some adaptations to ensure compatibility with legacy, like this: https://github.com/angular/angular/commit/e99d721
Changes app wide
Do I have to go through my whole app and start fixing things?
I mean, are main functionalities reworked in such way that I will have to review many of them?
Or, are there many build/core incompatibilities that will keep me days occupied fixing compile errors/warnings instead of developing?
I am not asking for someone to do the research for me, I am asking people that maybe already went through this process or simply know well both versions in order to give me some experience tips, clarifications, etc.
At the moment, I am doing my research here:
https://github.com/angular/angular/blob/master/CHANGELOG.md
http://angularjs.blogspot.it/2017/03/angular-400-now-available.html
https://learninglaravel.net/angular-4-new-features-and-improvements
UPDATE
I just migrated to Angular 4. The link that #PierreDuc put in his answer is a very nice tool to have a decent guideline in the migration process.
I would recommend:
Read new features and update yourself with Angular 4. This was specially useful: https://angularjs.blogspot.it/2017/03/angular-400-now-available.html
Follow Angular's guideline and modify your project: https://angular-update-guide.firebaseapp.com/
I would also recommend to commit your current project, create a new branch in your dev repository and proceed with migration in that branch.
An issue that I encountered:
Input, Output and ContentChild will be imported from a wrong path.
My case:
import { Component, OnInit, OnDestro } from '#angular/core';
import { Input, ContentChild } from "#angular/core/src/metadata/directives";
Solution:
import { Component, OnInit, OnDestroy, Input, ContentChild } from '#angular/core';
If you check the changelog there are a couple things you need to keep in mind:
Before updating
Ensure you don't use extends OnInit, or use extends with any lifecycle event. Instead use implements <lifecycle event>.
Stop using DefaultIterableDiffer, KeyValueDiffers#factories, or IterableDiffers#factories
Stop using deep imports, these symbols are now marked with ɵ and are
not part of our public API.
Stop using Renderer.invokeElementMethod as this method has been
removed. There is not currently a replacement.
During the update
Update all of your dependencies to version 4 and the latest typescript.
If you are using Linux/Mac, you can use: npm install
#angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}#4.0.0
typescript#latest --save
If you use animations in your application, you should import
BrowserAnimationsModule from #angular/platform-browser/animations in
your App NgModule.
Replace RootRenderer with RendererFactory2.
Replace Renderer with Renderer2.
After the update
Rename your template tags to ng-template.
Replace OpaqueTokens with InjectionTokens.
If you call DifferFactory.create(...) remove the ChangeDetectorRef
argument.
Replace ngOutletContext with ngTemplateOutletContext.
Replace CollectionChangeRecord with IterableChangeRecord
source
Angular team has announced , let's not call angular 2 or angular 4 let's call it Angular and there will be major update for every 6 months.I have faced the issue in angular v4.0.0 so change the configuration in webpack
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)#angular/,
helpers.root('./src'), // location of your src
{} // a map of your routes
),
And install #angular/animations package and import in app.module.ts file
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
#NgModule({
imports: [
BrowserAnimationsModule
]
})
I will prefer to update to latest version of angular. Angular V4.0.0 has reduced the packages weight and they have increased the performance.

After bundling my aurelia app I get a: No PLATFORM.Loader error

After bundling a simple aurelia application with jspm bundle-sfx I get the following error:
No PLATFORM.Loader is defined and there is neither a System API (ES6) or a Require API (AMD) globally available to load your app.
An example application: https://github.com/Baudin999/jspm-bundling-test
You can use: npm run setup:dev in a non windows env to switch back to the dev settings (which is just a comment/uncomment in the ./src/client/index.html) and you can use npm run setup:prod to switch back to the production environment, bundling will automatically be triggered. all other scripts can be found in the package.json.
I can't link to other questions because I haven't found any questions which relate to this problem. I "think" (which means absolutely nothing) that this might be related to the fact that aurelia needs a full loader even when bundling with bundle-sfx but I haven't found any ways to solve the error.
EDIT (25/01/2017 17:16): I've found out that the error is because I import the aurelia-bootstrapper.
As soon as I add: import * as bootstrapper from 'aurelia-bootstrapper'; I get the error
Please add the code how do you bootstrap your aurelia app.
There is nothing actually to import from bootstrapper apart from bootstrap function.
Which you would use in case of custom manual bootstrapping.
like in
import { bootstrap } from 'aurelia-bootstrapper'
const configure: (au: Aurelia) => {} = async function (au: Aurelia) {
au.use
.standardConfiguration();
await au.start()
au.setRoot() // or au.enchance()
})
bootstrap(configure)
in a happy path scenario with jspm - you System.import('aurelia-bootstrapper')
and it takes over finding the root node of your app and the script to configure Aurelia (main by default)
Have a look at Bootstrapping Aurelia in the docs
Oh.. and bundle-sfx is not supported there are other means to bundle aurelia apps using jspm