Migrating from SDK v1.2.x to v1.3.0
Guide for upgrading from Petnow SDK v1.2.x to v1.3.0.
iOS Changes
1. Required captureSessionId parameter when calling initializeCamera()
Starting from v1.3.0, you must pass the captureSessionId obtained from the server when calling initializeCamera().
// ❌ v1.2.x
try await cameraViewModel.initializeCamera(
licenseInfo: licenseInfo,
initialPosition: .back
) { result in
// ...
}
// ✅ v1.3.0
let sessionId = try await createCaptureSessionFromServer() // Call server API
try await cameraViewModel.initializeCamera(
licenseInfo: licenseInfo,
initialPosition: .back,
captureSessionId: sessionId
) { result in
// ...
}Breaking Change
If you don't pass captureSessionId, you will get a compilation error. You must call the server's POST /api/capture-sessions API to generate a session ID before passing it.
2. Initialization State Check Method Changed
v1.2.x: Check initialization with previewLayer
// ❌ v1.2.x
if cameraViewModel.previewLayer != nil {
// Camera is initialized
showCameraView()
}v1.3.0: Use isInitialized
// ✅ v1.3.0
if cameraViewModel.isInitialized {
// Camera is initialized
showCameraView()
}Reason for change: The previewLayer property has been removed. To check initialization status, use the explicit isInitialized property.
Breaking Change
CameraViewModel.previewLayer has been completely removed. If you were only using it to check initialization status, replace it with isInitialized.
If you actually need the Preview Layer, you can create it directly using cameraViewModel.captureSession:
let previewLayer = AVCaptureVideoPreviewLayer(session: cameraViewModel.captureSession)Android Changes
Required captureSessionId parameter when creating Fragment
Starting from v1.3.0, you must pass the captureSessionId obtained from the server as arguments when creating PetnowCameraFragment.
// ✅ v1.3.0
class MyCameraFragment : PetnowCameraFragment() {
companion object {
fun newInstance(captureSessionId: UUID) = MyCameraFragment().apply {
arguments = Bundle().apply {
putString(ARG_CAPTURE_SESSION_ID, captureSessionId.toString())
}
}
}
}
// Usage
val sessionId = createCaptureSessionFromServer() // Call server API
val fragment = MyCameraFragment.newInstance(sessionId)Breaking Change
If you don't pass captureSessionId, the Fragment will terminate immediately. You must call the server's POST /api/capture-sessions API to generate a session ID before passing it.
Migration Checklist
Common
- Have you implemented the server
POST /api/capture-sessionsAPI to generatecaptureSessionId?
iOS
- Have you changed
initializeCamera()calls to passcaptureSessionId? - Have you changed
previewLayerusage code toisInitialized?
Android
- Have you passed
captureSessionIdas arguments when creating Fragment?
Troubleshooting
Q. I was using previewLayer, what should I do?
A. Create it directly from captureSession:
// v1.2.x
let previewLayer = cameraViewModel.previewLayer
view.layer.addSublayer(previewLayer)
// v1.3.0
let previewLayer = AVCaptureVideoPreviewLayer(session: cameraViewModel.captureSession)
previewLayer.videoGravity = .resizeAspectFill
previewLayer.frame = view.bounds
view.layer.addSublayer(previewLayer)Additional Information
- iOS Changelog - Complete iOS changes
- Android Changelog - Complete Android changes