Page 1 of 1

Return to last card

Posted: Wed Dec 25, 2013 8:16 pm
by itay1023
Hi All,
Is it possible to do at my iPhone app in LC that when i close the app on the iOS device (but doesn't quit it) and when i come back,
the card and the content that was when i closed the app will appear?


Best regards,
Itay :)

Re: Return to last card

Posted: Wed Dec 25, 2013 8:23 pm
by endernafi
This issue has been covered many times,
but in a nutshell:

Code: Select all

on preOpenStack
   local tFile, tLastOpenCard
   
   put (specialFolderPath("cache") & "/lastOpenCard.txt") into tFile
   if there is a file tFile then
      put url("file:" & tFile) into tLastOpenCard
      if exists(card tLastOpenCard) then
         go card tLastOpenCard
      end if
   end if
end preOpenStack

on closeStack
   put the short name of this card into url("file:" & specialFolderPath("cache") & "/lastOpenCard.txt")
end closeStack
For further options, please do a forum search...


Best,

~ Ender Nafi

Re: Return to last card

Posted: Wed Dec 25, 2013 8:37 pm
by itay1023
It does't save the content on the last opened card.

Re: Return to last card

Posted: Wed Dec 25, 2013 8:40 pm
by endernafi
That's exactly why I've said:
For further options, please do a forum search...
Best,

~ Ender Nafi

Re: Return to last card

Posted: Wed Dec 25, 2013 8:58 pm
by endernafi
I must add something.

This was the old method, i.e. prior iOS 7.
As far as I know, iOS 7 brought background run to all apps without special permissions, just like Android.
So theoretically, Livecode apps should preserve the current state when re-opening without special coding; again, just like Android.
But they don't.

I suspect Livecode still doesn't support this.

I was thinking to direct this question to the support team;
when I do, I'll share their reply.

However, even Livecode supports this in the future;
you have to code the method I've mentioned in the previous post to support iOS 5, 6, etc.


About preserving the content;
searching the forum and reading other solutions will just give you an idea, an insight.
Because, your app is unique and you have to code differently to preserve your content for every each one of your apps.

When closing the stack, you have to record the state of that card in addition to the short name of it.
Nobody but you can know the content and the current state of it.
Positions of the buttons, sizes of the images, contents of the field, etc.
Record them into the same text file, then read them back in the preOpenStack,
then construct your card according to that info.


Hope it helps,

~ Ender Nafi