0

I have a hybrid app which uses Ionic and IBM's Mobilefirst platform. During login we get a cookie from the authentication service. I have to remove this cookie on logout or next time the user can log in even with incorrect credentials.

So during logout I call WL.Client.reloadApp() before going back to login screen. This clears the cookies and then login works correctly in Android and browsers. But in iOS cookies aren't cleared on reload and having searched I came across a solution to clear cookies using native code.

But my confusion is where do I add this native code? There are a few initialization methods in my application's default .m file. I have tried adding the code to clear cookies in -(void)wlInitDidCompleteSuccessfully. But this block doesn't seem to be executed on reloading.

Any suggestion on what I should try to fix this problem.

Community
  • 1
  • 1
RamY
  • 492
  • 1
  • 5
  • 20

1 Answers1

1

Two options:

  1. Use the WL.Client.deleteCookie(name) API to clear the cookie.
  2. Write a simple Cordova plugin (https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/adding-native-functionality/) to clear the cookies or google for 'cordova clear cookies' to find such plugins in the market.
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • the first solution doesn't work. As to the second solution. I'm using Mobilefirst Studio with Eclipse. I have seen one of your [answers](http://stackoverflow.com/questions/37023501/adding-third-party-cordova-plugin-in-ibm-mobile-first-7-1-using-eclipse), that to add Cordova plugin I need to use cli only or the workaround mentioned there for Studio plugin.Is this true even if I update to v8.0 of MobileFirst Studio? – RamY Sep 26 '16 at 10:20
  • 1
    In 7.1 you can create your own custom Cordova plugin and this is documented in the tutorials for 7.1 (answered updated with link). v8.0 is completely different from 7.1 - you do not create Hybrid apps, rather you create Standard Cordova apps, which thus allow you to also use Cordova Plugman to install 3rd party plugins. – Idan Adar Sep 26 '16 at 10:23