Base solution for your next web application
Open Closed

Base app working on Android by not on IOS #6922


User avatar
0
JasonC created

I am still working with a relatively unmodified ASPZero install. I have gotten all the base stuff working except for IOS app.

I did get the Andoird app working on a simulator after I changed the DefaultHostUrl to my live url (It was just stuff at the splash screen).

However when I sideload an IPA or run the base app in a simulator I get the splash screen and a second later an error message "A problem occurred while trying to communicate with the server. Do you want to try again?"

I can hit the APIs and that is the only server I can think of that it would communicate with? And it does work in the Droid app and it is my understanding that it is using the same mobile client code to connect for both types of app compiles.

Have not debugged an ios app before but this seems like something basic missing.

Any suggestions where to look?


15 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    Hi,

    iOS Simulator works on your MAC but Android emulator works on your local computer. So these are different computers. Try to access

    • http://YourIP:22742/AbpUserConfiguration/GetAll (for Web.Host)
    • http://YourIP:62114/AbpUserConfiguration/GetAll (for Web.MVC)

    on the MAC's safari browser. See if there's a connection problem or not.

    Also see

    • https://support.aspnetzero.com/QA/Questions/4520#answer-a8f87f6e-69d1-4b61-a611-4a5ba7c21f1f
    • https://support.aspnetzero.com/QA/Questions/5583#answer-867de663-b456-4da3-8326-cc0772de1ffd
  • User Avatar
    0
    JasonC created

    I am remotely connecting to a Mac server from visual studio. I have my provising profile all set up and am able to compile to ipa file and run the iOS simulator fine. On the simulator and when running on multiple actual iPhones / iPads all give me the same connection error. I am not running mvc project from visual studio and the android app works fine (which is connecting via same apis from what I can see).

    <br> <br>

  • User Avatar
    0
    alper created
    Support Team

    As I stated, android and ios works on different computers. The simulator that works on your computer is just a remote desktop app to your MAC. So go to your MAC, open the lid, open Safari and navigate to http://YourLocalDevelopmentComputerIpAddress:22742/AbpUserConfiguration/GetAll
    and see if you can retrieve some JSON data.

  • User Avatar
    0
    JasonC created

    Yes I can go on the mac and browse to to the server address (I set up both host and mvc at those ports in order to test this) and get back data.

    I've tried changing the <span class="colour" style="color: rgb(0, 0, 0);">DefaultHostUrl to both the host and mvc addresses and both times it has worked fine in the Android app and I have been able to update data just like I would expect.  Every time I use the iOS app no matter what way I have tried it (and I have tried multiple) I get the "A problem occurred while trying to communicate with the server. Do you want to try again?" after opening.</span>

  • User Avatar
    0
    alper created
    Support Team

    better to send your project to [email protected]. you can share it privately on your google drive or dropbox or one drive and send us the link.

  • User Avatar
    0
    JasonC created

    Ok I have sent the share.

  • User Avatar
    0
    alper created
    Support Team

    thanks @JasonC. we have recieved your project. After our investigation, we'll write back to you.

  • User Avatar
    0
    alper created
    Support Team

    Your zip file password protected. When you send the password, we'll check it.

  • User Avatar
    0
    JasonC created

    Sorry forgot about that, password sent.

  • User Avatar
    0
    alper created
    Support Team

    First of all, I delete all BIN & OBJ folders with Delete-BIN-OBJ-Folders.bat. Then rebuild solution. Changed ApiConfig.DefaultHostUrl = "http://localhost:22742/"; Modified start-host.batto start Web.Host project with the port 22742. See my screenshots to follow the rest... And make the corresponding changes for you.

    My local (Windows) IP address: 192.168.1.105

    My MAC IP address: 192.168.1.101

    Change my local IP address

    Extra: Bug on seed code when migration

    start-host.bat starts Web.Host

    ApiUrlConfig.cs

    Start Web.Host (by running start-host.bat)

    Finally set mybarnco.Mobile.iOS as startup project and run it. I can successfully see the iOS login page and the rest.

  • User Avatar
    0
    JasonC created

    Ok thanks. A few things.

    I update the bug on seed code. I deleted the binand obj folders.

    So my mac I pair with to compile/use xcode simulator is not on the same network as my pc.

    That is why I am not running the DefaultHostUrl = "http://localhost:22742/";

    but rather pointing it to the deployed web.host I have out there. I have tested and I can manually connect to that service just fine from the mac. I also use that same value with my andorid simulator and that connects and runs just fine. You can try that url and see that.

    This all would seem to make sense if I was debugging and had a mac on the same network, but I am not trying to debug and the mac is an external that I am pairing with.

    However since I am entered in the correct production url and compiling the IPA and simulator in release mode should it not work?

    Thanks

  • User Avatar
    0
    alper created
    Support Team

    As far as I know, MAC and your development computer must be on the same network. Otherwise there might be firewall / port forwarding etc... issues...

    Your case is a bit out of the AspNet Zero development. Maybe you should ask it to Microsoft Xamarin team.

  • User Avatar
    0
    JasonC created

    I am confused how this is out of aspnet zero?

    Does the ios app not have the ablity to run in production mode?

    The only thing I am changing is the url to point to a non-localhost host. Based on the code it should just use that url (not not replace localhost with the ip address code). I can access the web service production url and port fine from the mac (and any computer) and it works fine on the android.

    Is there some sort of setting that needs to be set to allow the ios app to consume webservices from external networks? Again it works fine with the droid app, it is the ios app only that give me connection error.

  • User Avatar
    0
    alper created
    Support Team

    you can run it externally but you cannot connect to simulator while you are not on the same network. this is totally out of the existing AspNet Zero app. To test this case, create a scratch Xamarin iOS app and try to connect externally with simulator. you'll see the same result.

    publish your app to App Store and it'll work. by the way you need HTTPS connection to be able to work for iOS. check out

    • https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/connecting-to-mac/
    • https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/connecting-to-mac/troubleshooting
    • https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/config-options

    I strongly suggest you to create a scratch Xamarin App and test your network to see if the problem is related with the existing AspNet Zero app.

  • User Avatar
    0
    JasonC created

    "by the way you need HTTPS connection to be able to work for iOS."

    That's the info I needed!

    So yes once I changed my DefaultHostUrl to https rather than http it worked. I knew it had to be something simple. I guess the fact that the http works on andorid threw me off, but no where did I come across it had to be https to run for ios.

    I now have the basic no mod app running for android (simulator only), and ios (both simulator and sideloading onto a device).

    Thanks