Walkthrough (or tutorial)
This component helps you demonstrate or explain your app to new users. You can showcase the main features of your app.
For the walkthrough we use the ion-slides component with four slides. Of course you can use as many as you want.

How to use this component?

To modify this component go to src/app/walkthrough/walkthrough.page.html and change the content inside each <ion-slide>
We use SVGs to create the "wave" effect from the backgrounds. You can modify the svgs by using the link we provide in the code.
By pressing the SKIP button, the user will be taken to the last screen of the walkthrough with the option to go to the Authentication page or to Getting Started.
Last page of Walkthrough

Only show the Walkthrough for first time users

If you want to show the walkthrough only the first time the user opens the app, you can use the Capacitor Storage API to add a flag. Let's see how to do this.
So, the first time the user opens the app, he will start with the walkthrough, then, all the following times he opens the app, he will be redirected to the log in page. Let's see how to do this.
On the Walkthrough page add the following code to set a visitedWalkthrough key with a true value on the ngOnInit method.
1
ngOnInit(): void {
2
// save key to mark the walkthrough as visited so the next time the user vistis the app, he would be redirected to log in
3
Storage.set({
4
key: 'visitedWalkthrough',
5
value: 'true'
6
});
7
}
Copied!
Then, add a CanActivate angular guard to your walkthrough route. Also, don't forget to add this guard to your routing definition.
This guard is evaluated each time the user tries to access the walkthrough route. Here we use again the Capacitor Storage API to get access to our visitedWalkthrough key.
If the key doesn't exist, our const { value } will have a null value so it will be different from "true", then the canActivate guard returns true.
walkthrough.guard.ts
walkthrough.module.ts
src/app/walkthrough/walkthrough.guard.ts
1
import { Injectable } from '@angular/core';
2
import { CanActivate, Router } from '@angular/router';
3
import { Plugins } from '@capacitor/core';
4
5
const { Storage } = Plugins;
6
7
@Injectable()
8
export class WalkthroughGuard implements CanActivate {
9
constructor(private router: Router) {}
10
11
async canActivate(): Promise<boolean> {
12
const { value } = await Storage.get({ key: 'visitedWalkthrough' });
13
14
if (value === 'true') {
15
// this is a returning user, don't show him the walkthrough
16
this.router.navigate(['auth']);
17
return false;
18
19
} else return true;
20
}
21
}
Copied!
src/app/walkthrough/walkthrough.module.ts
1
const routes: Routes = [
2
{
3
path: '',
4
component: WalkthroughPage,
5
canActivate: [WalkthroughGuard]
6
}
7
];
Copied!
That's all! Please contact us ([email protected]) if you have any questions.
Last modified 8mo ago