Pocketbase mobile is used to generate android and ios packages for using pocketbase in mobiles
Make sure gomobile is installed
run : gomobile bind -androidapi 19
for Android, this will generate pocketbaseMobile.aar
, import this in android and use
run : gomobile bind --target ios
for IOS or try : gomobile bind -ldflags='-extldflags=-libresolv.tbd' -target=ios
Checkout pocketbase_server_flutter
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.rohitsangwan01:pocketbase_mobile:Tag'
}
Use CoroutineScope to call pocketbase methods ( import kotlin coroutines libraries)
private val uiScope = CoroutineScope(Dispatchers.Main + Job())
To start pocketbase
// use dataPath where app have write access, for example temporary cache path `context.cacheDir.absolutePath` or filePath
uiScope.launch {
withContext(Dispatchers.IO) {
PocketbaseMobile.startPocketbase(dataPath, hostname, port, enableApiLogs)
}
}
To stop pocketbase
uiScope.launch {
withContext(Dispatchers.IO) {
PocketbaseMobile.stopPocketbase()
}
}
To listen pocketbase events, and also handle custom api requests
pocketbaseMobile
have two custom routes as well ,/api/nativeGet
and /api/nativePost
, we can
get these routes in this callback and return response from kotlin
PocketbaseMobile.registerNativeBridgeCallback { command, data ->
this.runOnUiThread {
// Update ui from here
}
// return response back to pocketbase
"response from native"
}
Download PocketbaseMobile.xcframework.zip
and extract, then add this to ios project,
If getting error related to Undefined symbol
, Select Build Phases
and in Link Binary With Libraries
section, click on +
button and search for libresolv.tbd
and choose from result and click on Add
checkout this for more info
Checkout Pocketbase Server Flutter for android and ios implementation in flutter
Checkout Pocketbase Server Android for native android implementation
- To create a secure localChat server or maybe a file storage system or anything which provided by pocketBase
- To use an old android device as local server to host PocketBase
- To use a mobile app which is based on PocketBase, so we can simply run PocketBase server within mobile and show demo of our application, useful for someone who don't want to host pocketBase yet
- To use Pocketbase as a College project,and for students team who want to show demo of a mobile app but can't afford hosting or something , so all they have to do is , run pocketBase server from there mobile and their main app which is based on pocketBase is ready to use
Checkout a Flutter chatApp built using pocketbase: flutter_pocketbase_chat