Offline Support
Learn how you can deliver experiences for your users when they are offline.
Offline mobile applications allows users to access the mobile apps without internet. Some examples of offline apps are Amazon Kindle, Google Drive.
While the above apps say they are offline, the content that is accessible inside them needs to be downloaded when online. Your app is most likely to work in similar way.

Offline support using default publish feature:

If you are publishing your projects directly using in-built targeting features, the offline support is by default.
Condition: Your users need to be online once so that the experience you want to deliver is downloaded locally for them.

Offline support using ProjectID:

Since the projects published with ProjectIDs are triggered from your codebase, we suggest you explicitly sync the projects whenever the connection is present (ideally start of the app). This ensures the availability of the entire experience on users device while on offline mode.
To sync the offline projects at the start of the app add the below lines of code at the start of the app:
Android
Swift
Objective-C
ReactNative
Cordova(Android)
Cordova (iOS)
Xamarin Android
Xamarin iOS
Ionic
List<String> offlineSyncList = new ArrayList<>();
offlineSyncList.add("PROJECT_ID_1");
offlineSyncList.add("PROJECT_ID_2");
Leap.offlineSync(offlineSyncList);
var offlineSyncList:[String] = []
offlineSyncList.append("PROJECT_ID_1")
offlineSyncList.append("PROJECT_ID_2")
Leap.shared.offlineSync(offlineSyncList)
NSMutableArray<NSString *> *offlineSyncList = [[NSMutableArray alloc] init];
[offlineSyncList addObject:@"PROJECT_ID_1"];
[offlineSyncList addObject:@"PROJECT_ID_2"];
[[Leap shared] offlineSync:offlineSyncList];
let projectIDs = ['PROJECT_ID_1', 'PROJECT_ID_2'];
LeapReactNative.offlineSync(projectIDs);
let projectIDs = ['PROJECT_ID_1', 'PROJECT_ID_2'];
cordova.plugin.LeapAndroid.offlineSync(projectIDs);
let projectIDs = ['PROJECT_ID_1', 'PROJECT_ID_2'];
cordova.plugin.LeapiOS.offlineSync(projectIDs);
string[] projectIds = {"PROJECT_ID_1","PROJECT_ID_2"};
Leap.OfflineSync(projectIds);
string[] projectIds = {"PROJECT_ID_1", "PROJECT_ID_2" };
Leap.Shared.OfflineSync(projectIds);
let projectIDs = ['PROJECT_ID_1', 'PROJECT_ID_2'];
LeapPlugins.offlineSync({projectIDs:projectIds});
Once the projects are synced, you can start the project using the below lines of code:
Android
Swift
Objective-C
ReactNative
Cordova(Android)
Cordova (iOS)
Xamarin Android
Xamarin iOS
Ionic
Leap.embedProject("PROJECT_ID_1");
Leap.shared.embedProject("PROJECT_ID_1");
[[Leap shared] embedProject:@"PROJECT_ID_1"];
LeapReactNative.embedProject('PROJECT_ID_1');
cordova.plugin.LeapAndroid.embedProject('PROJECT_ID_1');
cordova.plugin.LeapiOS.embedProject('PROJECT_ID_1');
Leap.EmbedProject("PROJECT_ID_1");
Leap.Shared.EmbedProject("PROJECT_ID_1");
LeapPlugin.embedProject({projectId:"<GENERATED_PROJECT_ID>"});
If you face any issues while implementing the above solutions, feel free to write to us at [email protected]
Copy link
Outline