Code Monkey home page Code Monkey logo

Comments (38)

mattwoberts avatar mattwoberts commented on August 14, 2024

Wonder if it's related to this:

#25

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Sorry to bump this, I was just wondering if anyone else has seen this - it seems pretty bad, since it renders the whole offline stuff as unusable.

I'll try removing cordova and re-building the app, see if that makes a difference.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

Hi Matt, I'm looking at this now, sorry for the delay, we've been focused on 0.5 upcoming. So you are saying that the "online" event code doesn't seem to be working? it accurately goes offline, but never comes online.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

Hi Matt,
I just tried a few apps in the iOS store that I know are using Manifoldjs and they all came right back online, are you seeing any errors in the console when you go back online?
Offline is handled with different code in iOS than it is with other platforms:
https://github.com/manifoldjs/ManifoldCordova/blob/a31b045317d0b63974141b7c9d21434343135dd5/src/ios/CDVHostedWebApp.m
so it could be a version issue or something.

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

That's weird. I'll try to generate a vanilla app and see if I can recreate.
I'll post an update t-row, cheers for taking a look!

On Tue, 16 Feb 2016 22:23 Jeff Burtoft [email protected] wrote:

Hi Matt,
I just tried a few apps in the iOS store that I know are using Manifoldjs
and they all came right back online, are you seeing any errors in the
console when you go back online?


Reply to this email directly or view it on GitHub
#59 (comment)
.

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Hi,

So I finally got round to testing this.

I'm testing on a real iphone 4, which has wifi connection, but no data network (there is no sim card in the phone).

I've just generated a new manifoldjs app with this command:

manifoldjs http://www.bbc.co.uk -d bbcapp -p ios

The app generates fine. I build and launch on the device, and then disconnect from the usb cable. Here's what I observe:

When I load the app, and then go aeroplane mode, nothing happens until I click a link on the page, at which point I get the offline page (by design?)
When I have the offline screen displayed, and then turn aeroplane mode off, I never return back to the app - I remain stuck in the offline page. The ony way back is for me to force-quite the app and launch it again.

Here's some output from xcode which may or may not be of use :)

When I first go into aeroplane mode:
2016-02-22 09:20:46.747 WwwBbcCoUk[236:8539] Invalid callback id received by sendPluginResult
While in aeroplane mode, I try to click a link:

2016-02-22 09:21:08.159 WwwBbcCoUk[236:8539] Resetting plugins due to page load.
2016-02-22 09:21:08.161 WwwBbcCoUk[236:8539] Received a navigation start notification.
2016-02-22 09:21:08.192 WwwBbcCoUk[236:8539] Failed to load webpage with error: The Internet connection appears to be offline.
2016-02-22 09:21:08.197 WwwBbcCoUk[236:8539] Received a navigation failure notification. error: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLStringKey=http://www.bbc.co.uk/news, NSErrorFailingURLKey=http://www.bbc.co.uk/news, NSLocalizedDescription=The Internet connection appears to be offline., NSUnderlyingError=0x15e2f8b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=8, NSErrorFailingURLStringKey=http://www.bbc.co.uk/news, NSErrorFailingURLKey=http://www.bbc.co.uk/news, NSLocalizedDescription=The Internet connection appears to be offline., _kCFStreamErrorDomainKey=12}}}

And again, when I turn OFF aeroplane mode:

2016-02-22 09:23:06.817 WwwBbcCoUk[236:8539] Invalid callback id received by sendPluginResult

Finally, here's the version of the plugins I'm using:

Matts-MacBook-Pro:cordova:% cordova plugin list                             
cordova-plugin-hostedwebapp 0.2.1 "HostedWebApp"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-whitelist 1.0.0 "Whitelist"

Any ideas?

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Can anyone else confirm these steps produce the same issues as me on a different iphone device - @boyofgreen ?

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

Hi Matt, I only have a simulator at this time. @DaveVoyles can you do a base app and test this for Matt. The offline page is suppose to go on by itself when network is lost, so I think there must be something up with network-information

@mattwoberts I'll try this with the new version tonight on simulator and see if I get the same issue.

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Hi @boyofgreen. I just tried that app I generated above on the simulator (iphone 6), and it works perfectly.

I then tried the same app deployed to another real device. This time it was my wifes iphone 5s. This behaves in much the same way as I reported - aeroplane mode doesn't get picked up until you try to navigate somewhere, and once in offline mode you don't come back.

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

bump Anyone else seeing this?

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

More updates re: this. I've upgraded everything, so I'm on manifoldjs 0.5.0, but the issue remains.

Created a new app as before using this new manifoldjs. Works perfectly on the simulator, but on 3 different test devices, it doesn't work. I tried debugging the app, didn't get too far since i don't know 'owt about objective c, but all I can see is that this isn't being hit:

// Handles notifications from the network-information plugin and shows the offline page whenever
// network connectivity is lost. It restores the original view once the network is up again.
- (void)updateConnectivityStatus:(NSNotification*)notification
{

.. when you're on a real device, although it does get hit when you test on the sim.

:(

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

I'm going to work round this by disabling the offline support and instead using the notifications from cordova network-information - the javascript notification hooks provided by that plugin are working fine for me, but no events are firing for the offline support added to this plugin.

However, I'm confused why no-one else is reporting to see this issue.. @boyofgreen did you manage to test this on a real device?

Matt

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

I have not yet. This is an interesting one. Clearly there is a bug, but we should also just give you the ability to disable to offline page as a manifest value.

from manifoldcordova.

DaveVoyles avatar DaveVoyles commented on August 14, 2024

Did you have to add anything to your info.plist iOS file to get this to run?

If I wrap my own site (DaveVoyles.com) then try to run it through my iphone 6 with xCode, it throws an error about "App Transport Security policy requires the use of a secure connection". Thought this SO post would have helped, but no dice.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

So with the latest version of iOS, it is https only by default, but you can go into your plist (I don't remember the value, but I remember it being evident) and allow for http. if you can't find it, I'll crack open an app I did it for and see what it was

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

I haven't edited this for my app, my site is https

from manifoldcordova.

DaveVoyles avatar DaveVoyles commented on August 14, 2024

@mattwoberts Got it working. I just plugged the phone in and out a bunch and it suddenly removed that error. shrug.

Steps taken:

  1. Created a new ManifoldApp from the ManifoldJS generator page
  2. Open project in xCode & Changed info.plist to allow for Arbitrary loads, to load my default page
  3. Manifold app loads www.DaveVoyles.com
  4. When I turn on airplane mode the page hides and the text "It looks like you are offline. Please reconnect to use this application" appears.

Is that the expected behavior?

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Cheers. Yeah that's the expected behaviour. Does it come back when you turn aeroplane off?

So the only difference is that you edited your plist, which shouldn't be an issue for me since I'm HTTPS.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

and he probably has a SIM card in his phone, maybe that is the difference?

from manifoldcordova.

DaveVoyles avatar DaveVoyles commented on August 14, 2024

No, it does not come back when I turn airplane mode off and reconnect to the internet.

Yes, I have a SIM in this phone as well.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

Thanks Dave. Something must have changed under us. There are a number of iOS issues raised on the tracker . We need to make sure we have it implemented correctly, then raise an issue if need be.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

looks like the issue would be here:
https://github.com/manifoldjs/ManifoldCordova/blob/a31b045317d0b63974141b7c9d21434343135dd5/src/ios/CDVHostedWebApp.m#L346

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Hi. I'm testing on both a phone with and without a sim card - same issue on
both.

That code you highlight never gets hit for me on iOS when I go
offline/online.. Weird eh.

On Wed, 2 Mar 2016 16:38 Jeff Burtoft, [email protected] wrote:

looks like the issue would be here:

https://github.com/manifoldjs/ManifoldCordova/blob/a31b045317d0b63974141b7c9d21434343135dd5/src/ios/CDVHostedWebApp.m#L346


Reply to this email directly or view it on GitHub
#59 (comment)
.

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

yea, I saw something about the event name changing, maybe we are listening to an old even name

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

If I knew anything at all about obj-c I'd take a closer look :) might have a nosey anyway

from manifoldcordova.

DaveVoyles avatar DaveVoyles commented on August 14, 2024

I'm in the same boat -- I don't know any obj-c.

I agree, looks like it's in the exact spot you mentioned above, but you said it's never hitting that breakpoint, right?

from manifoldcordova.

f2bo avatar f2bo commented on August 14, 2024

As you've already noted, it works in the simulator and I'm afraid I don't have a device right now to test this, but if you place a breakpoint in the following line of the Plugins/CDVReachability.m file, does it get hit when the network status changes?

https://github.com/apache/cordova-plugin-network-information/blob/master/src/ios/CDVReachability.m#L103

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

@mattwoberts would you be able to try that? My guess is that it will run once, but not when it goes back online.

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Yes, it's on my to-do list tonight - I'll get back to you in a couple of hours!

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

@boyofgreen @f2bo Hi - just tested, and a breakpoint on that line is never being hit for me - the javascript offline / offline code is firing for me, but never that breakpoint, not even first load.

from manifoldcordova.

f2bo avatar f2bo commented on August 14, 2024

Hi @mattwoberts.

Interesting. I mentioned placing the breakpoint in the line that actually posts the notification, but just to be sure, can you make sure that the CDVReachabilityCallback method doesn't get called at all? There's some validation code in that method that might cause it to skip the line with the breakpoint.

There's another breakpoint that you can set that might help to understand what is going on. Can you put a breakpoint in the sendPluginResult method?

https://github.com/apache/cordova-plugin-network-information/blob/3968f2069dfc858244640215046b09649d8b2eb4/src/ios/CDVConnection.m#L41

Assuming it gets hit, make a note of the call stack leading up to that breakpoint both when transitioning from online to offline and offline to online. (The call stack for all threads can be examined in the Debug navigator pane on the left side of Xcode).

Also, I'm intrigued by the fact that you say that the javascript offline / online code is working despite the fact that the notification on the native side never gets fired. Since I can't reproduce the problem in the simulator, I'm trying to understand the code path that needs to execute for that to happen. Presumably, you are hooking the online / offline events with code similar to the following, correct?

    document.addEventListener('deviceready',  function () {
        document.addEventListener("offline", function () {
            console.log('Device is OFFLINE...');
        }, false);
        document.addEventListener("online", function () {
            console.log('Device is ONLINE...');
        }, false);
    }, false);

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Hi @f2bo

Right - here's my responses. I'm testing on an iphone 4 this time - it's the one that doesn't have a SIM card in it.

CDVReachabilityCallback - that method you asked me to breakpoint is not being hit at all. Ever. Just to be certain I wasn't doing something silly, I tested on a the simulator, and the breakpoints WERE hit without issue.

sendPluginResult:

Going from online to offline:

screen shot 2016-03-08 at 15 44 36

The stack looks the same going back again - am I looking for anything in particular?

Regarding the javascript API - yes absolutely, this is how I'm working around it for now. I listen to the events like this:

document.addEventListener("offline", offline, false); document.addEventListener("online", online, false);

And those functions fire perfectly, every time!

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

Thanks @mattwoberts , @f2bo and I will be together for the next few weeks and will have some real devices to test with, so we'll figure this out.

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

Hi. Just wondered if there was any update / progress on this. I've managed to work around it on my app, so it's not a major issue for me, but I'd ideally prefer to use this...

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

Hi Matt, we had to move it out of the 0.3 release (i know it's still tagged) since we didn't want to hold up the other changes with it. We have a 0.4 starting in two weeks, and we'll address it in that release, one way or another.
Sorry about the delay, but we haven't forgotten about you!

from manifoldcordova.

f2bo avatar f2bo commented on August 14, 2024

Hi @mattwoberts,

Sorry it took so long to get back to you but we are currently working on the next release and have started looking at this issue again.

I can't tell whether I've been able to reproduce the same symptoms that you report. In my tests, the application does detect changes in network connectivity correctly on a device (iPhone 6s - iOS 9.3) when the application is in the foreground. However, I did find a problem when the changes happen while the application is in the background. I've pushed a potential fix to the ios-offline-fix branch. It would be very helpful if you can test it and let us know if you notice any improvement.

The only changed file is src/ios/CDVHostedWebApp.m, so it's probably easiest to test by replacing that file in a copy of your project.

Otherwise, you can replace the plugin with the one in the ios-offline-fix branch of this repo. For example:

cordova plugin rm cordova-plugin-hostedwebapp
cordova plugin add https://github.com/manifoldjs/ManifoldCordova.git#ios-offline-fix

from manifoldcordova.

mattwoberts avatar mattwoberts commented on August 14, 2024

👍

Excellent work - just got round to testing it, and it worked perfectly for me, on all real devices I could find hanging around.

Cheers - what release do you think this will be in?

from manifoldcordova.

boyofgreen avatar boyofgreen commented on August 14, 2024

we are targeting 0.6 for the end of the month, it will be in that one.

from manifoldcordova.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.