0

i created an ionic capacitor app for the front end using angular and the backend with express node and mongodb, with cookies to storing the jwt , with testing the app with ionic serve in localhost it's work perfectly , but when i build the app with android studio , it's intsalled correctly and when i test it with both emulator and in my android phone i can't use it , i checked the connection between the ip adress of my pc , deploy the backend in heroku but still cant use my app .any help please

i m newer with creating ionic app , so i need some help to fix this problem

if i work with ionic serve it's works perfetcly , but for both emulator or enter image description hereandroid device i can't login , i have checked with postman that https://mihab-back.herokuapp.com/api/mihab/users workes perfectly , .thanks

cors configuration and server

ikat88
  • 11
  • 3

1 Answers1

0

I had similar issues in cases when the hardware permissions are not configured correctly. This might also happen when there is an error in your typescript code. Rarely, some typescript functions may work on desktop browsers but not on mobile devices or emulators.

  • any suggestions please? – ikat88 Apr 10 '23 at 14:11
  • I see that you have added the screenshots of the backend. There is no problem with the backend. When running your application just make sure you are calling a public ip and not your local ip. for which it would be better to host your api on a cloud and let your app use that ip instead of a local ip. – rajeshrapaka Apr 11 '23 at 12:30
  • yeah it's correct, i have deployed my backend with heroku and change the environement production to heroku app , and it's work , but i have other error that the token is not found when test the app with mobile phone, i stored when creating the user in the cookies , so how i can retrieve again in the mobilephone? – ikat88 Apr 11 '23 at 12:56
  • Glad the worked. If you are using REST API then using jwt is the way to go. You will need to create a middleware for authenticating a jwt token on login. you will need to send that token in a http header request which once again should get authenticated in the backend before it reaches the controller. Googling for examples may help. – rajeshrapaka Apr 12 '23 at 14:59
  • that i have done , i remove the send of the token by cookies , and send the token only wit hedears and it's work , please i think that using capacitor service are not the best practise to build a mobile app , because when using the google maps it's have many errors , also now i get errors using the google aut library from cotedrix capacitor, did you have any idea about make the login by google account? – ikat88 Apr 13 '23 at 15:50
  • I have used capacitor with google maps and did not face any issues. The initial setting up could be pretty confusing. Try to youtube for simon's videos on how to setup your ionic app for google authentication and google maps. Hope it helps. – rajeshrapaka Apr 19 '23 at 08:33
  • thanks for replying , i have used the capacitor google auth , and it's didnt work , it's give me error something wrong 10 , i have added the sha1 fingeprint to the projecty but the same error , can you help me pleaése? – ikat88 Apr 19 '23 at 13:32