1
- import { IonButton , IonContent , IonHeader , IonPage , IonTitle , IonToolbar , useIonViewWillEnter } from '@ionic/react' ;
2
- import { useCallback , useEffect , useState } from 'react' ;
3
- import { useHistory } from 'react-router' ;
4
- import ExploreContainer from '../components/ExploreContainer' ;
5
- import IntuneMAM , { IntuneMAMAppConfig , IntuneMAMGroupName , IntuneMAMPolicy , IntuneMAMUser , IntuneMAMVersionInfo } from '../IntuneMAM' ;
6
- import './Home.css' ;
1
+ import {
2
+ IonButton ,
3
+ IonContent ,
4
+ IonHeader ,
5
+ IonPage ,
6
+ IonTitle ,
7
+ IonToolbar ,
8
+ useIonViewWillEnter ,
9
+ } from "@ionic/react" ;
10
+ import { useCallback , useEffect , useState } from "react" ;
11
+ import { useHistory } from "react-router" ;
12
+ import ExploreContainer from "../components/ExploreContainer" ;
13
+ import {
14
+ IntuneMAM ,
15
+ IntuneMAMAppConfig ,
16
+ IntuneMAMGroupName ,
17
+ IntuneMAMPolicy ,
18
+ IntuneMAMUser ,
19
+ IntuneMAMVersionInfo ,
20
+ } from "@ionic-enterprise/intune" ;
21
+ import "./Home.css" ;
7
22
8
23
const Home : React . FC = ( ) => {
9
24
const history = useHistory ( ) ;
@@ -19,11 +34,11 @@ const Home: React.FC = () => {
19
34
async function getInitialData ( ) {
20
35
setVersion ( await IntuneMAM . sdkVersion ( ) ) ;
21
36
22
- IntuneMAM . addListener ( ' appConfigChange' , ( ) => {
23
- console . log ( ' App config change here' ) ;
37
+ IntuneMAM . addListener ( " appConfigChange" , ( ) => {
38
+ console . log ( " App config change here" ) ;
24
39
} ) ;
25
- IntuneMAM . addListener ( ' policyChange' , ( ) => {
26
- console . log ( ' Policy change here' ) ;
40
+ IntuneMAM . addListener ( " policyChange" , ( ) => {
41
+ console . log ( " Policy change here" ) ;
27
42
} ) ;
28
43
}
29
44
getInitialData ( ) ;
@@ -33,15 +48,19 @@ const Home: React.FC = () => {
33
48
async function getToken ( ) {
34
49
if ( user && user . upn ) {
35
50
try {
36
- const tokenInfo = await ( IntuneMAM as any ) . acquireTokenSilent ( {
51
+ const tokenInfo = await IntuneMAM . acquireTokenSilent ( {
37
52
scopes : [ "https://graph.microsoft.com/.default" ] ,
38
- ...user
53
+ ...user ,
39
54
} ) ;
40
55
setTokenInfo ( tokenInfo ) ;
41
- console . log ( ' Got token info' , tokenInfo ) ;
56
+ console . log ( " Got token info" , tokenInfo ) ;
42
57
} catch {
43
- console . error ( 'Unable to silently acquire token, getting interactive' ) ;
44
- const tokenInfo = await ( IntuneMAM as any ) . acquireToken ( ) ;
58
+ console . error (
59
+ "Unable to silently acquire token, getting interactive"
60
+ ) ;
61
+ const tokenInfo = await IntuneMAM . acquireToken ( {
62
+ scopes : [ "https://graph.microsoft.com/.default" ] ,
63
+ } ) ;
45
64
setTokenInfo ( tokenInfo ) ;
46
65
}
47
66
}
@@ -74,7 +93,7 @@ const Home: React.FC = () => {
74
93
if ( user ) {
75
94
await IntuneMAM . deRegisterAndUnenrollAccount ( user ) ;
76
95
}
77
- history . replace ( '/' ) ;
96
+ history . replace ( "/" ) ;
78
97
} , [ user ] ) ;
79
98
80
99
return (
@@ -90,15 +109,24 @@ const Home: React.FC = () => {
90
109
< IonTitle size = "large" > Blank</ IonTitle >
91
110
</ IonToolbar >
92
111
</ IonHeader >
93
- < h2 > { user ?. upn || ' No user' } </ h2 >
112
+ < h2 > { user ?. upn || " No user" } </ h2 >
94
113
< h5 > Token info:</ h5 >
95
- < textarea style = { { height : '200px' , width : '100%' , display : 'block' } } value = { JSON . stringify ( tokenInfo ?? { } , null , 2 ) } />
96
- < h5 > Intune MAM Version: { version ?. version || 'No version' } </ h5 >
97
- < h5 > Group name: { groupName ?. value || 'No group name' } </ h5 >
114
+ < textarea
115
+ style = { { height : "200px" , width : "100%" , display : "block" } }
116
+ value = { JSON . stringify ( tokenInfo ?? { } , null , 2 ) }
117
+ />
118
+ < h5 > Intune MAM Version: { version ?. version || "No version" } </ h5 >
119
+ < h5 > Group name: { groupName ?. value || "No group name" } </ h5 >
98
120
< h5 > Policy:</ h5 >
99
- < textarea style = { { height : '200px' , width : '100%' , display : 'block' } } value = { JSON . stringify ( policy ?? { } , null , 2 ) } />
121
+ < textarea
122
+ style = { { height : "200px" , width : "100%" , display : "block" } }
123
+ value = { JSON . stringify ( policy ?? { } , null , 2 ) }
124
+ />
100
125
< h5 > App Config:</ h5 >
101
- < textarea style = { { height : '200px' , width : '100%' , display : 'block' } } value = { JSON . stringify ( appConfig ?? { } , null , 2 ) } />
126
+ < textarea
127
+ style = { { height : "200px" , width : "100%" , display : "block" } }
128
+ value = { JSON . stringify ( appConfig ?? { } , null , 2 ) }
129
+ />
102
130
< IonButton onClick = { showConsole } > Show Diagnostics Console</ IonButton >
103
131
< IonButton onClick = { logout } > Log out</ IonButton >
104
132
</ IonContent >
0 commit comments