Push Wake
Not available yet. Push wake depends on the native iOS agent, which is on the roadmap and has not shipped. Today CMDOP runs on macOS and Linux, and the mobile story is the web UI in your phone’s browser — see Mobile. The walkthrough below is a preview of the planned capability.
Push wake uses Apple Push Notification Service (APNs) to wake a suspended CMDOP iOS app so it can execute operations. When the SDK sends a request to an offline device, the control plane delivers a silent push notification that wakes the app, restores the connection, and completes the operation — typically within 2 to 30 seconds.
iOS suspends apps in the background. Push wake uses Apple Push Notifications to wake the CMDOP app and execute operations.
What problem does push wake solve?
Without Push Wake:
iPhone app → background → suspended → connection lost
SDK request → timeout → fail
With Push Wake:
iPhone app → background → suspended
SDK request → push notification → app wakes → connection restored → successHow does push wake work?
How do I enable push wake?
How do I enable push wake in the iOS app?
- Open CMDOP app
- Go to Settings
- Enable “Background Operations”
- Allow notifications when prompted
How do I use push wake from the SDK?
Push wake is automatic when the device is offline:
from cmdop import AsyncCMDOPClient
# Open a remote client session; push_wake defaults to True
async with AsyncCMDOPClient.remote(api_key="cmd_xxx") as client:
# If the device is asleep, a silent push notification wakes it first
files = await client.files.list(
"marks-iphone",
"/Documents",
push_wake=True # Default is True
)How do I configure push wake?
How do I set a custom push wake timeout?
# Extend the timeout to 60 seconds for devices on slow networks
files = await client.files.list(
"marks-iphone",
"/Documents",
push_wake=True,
push_wake_timeout=60 # Wait up to 60 seconds
)How do I disable push wake?
# Skip push wake and fail immediately if the device is offline
try:
files = await client.files.list(
"marks-iphone",
"/Documents",
push_wake=False
)
except DeviceOfflineError:
print("Device is not connected")What are the push wake session states?
| State | Push Wake Needed | Wake Time |
|---|---|---|
| CONNECTED | No | Instant |
| BACKGROUND | No | < 1 second |
| SUSPENDED | Yes | 2-10 seconds |
| TERMINATED | Yes | 5-30 seconds |
What are the best practices for push wake?
How should I handle push wake timeouts?
# Wrap the call in asyncio.wait_for to enforce a hard timeout
try:
result = await asyncio.wait_for(
client.files.list("marks-iphone", "/Documents"),
timeout=30
)
except asyncio.TimeoutError:
print("Device didn't wake in time")How should I batch operations after a wake?
# Good: One wake, multiple operations back-to-back
# The device stays awake for ~30 seconds after the first request
await client.files.list("marks-iphone", "/Documents")
await client.files.read("marks-iphone", "/Documents/file.txt")
await client.files.download("marks-iphone", "/Documents/data.db", "./data.db")
# Device stays awake for ~30 seconds
# Avoid: Letting the device sleep between requests triggers extra wakes
await asyncio.sleep(60) # Device goes back to sleep
await client.files.list("marks-iphone", "/Documents") # Another wakeHow should I handle push wake failures?
from cmdop.exceptions import PushWakeError, DeviceOfflineError
# Catch specific exceptions to distinguish push delivery failures from offline
try:
files = await client.files.list("marks-iphone", "/Documents")
except PushWakeError:
print("Push notification failed to deliver")
except DeviceOfflineError:
print("Device is offline (no network)")How should I check device status before expensive operations?
# Query device status before starting a long-running operation
status = await client.system.status("marks-iphone")
if status.online:
# Device is reachable; proceed without push wake overhead
await expensive_operation()
else:
# Device is offline; consider notifying the user or queuing the task
print("Device offline, operation queued")What are the push wake limitations?
What iOS restrictions affect push wake?
- App must not be force-quit by user
- Background App Refresh must be enabled
- Device must have network connection
- Push notifications must be allowed
How does push wake affect battery life?
- Frequent wake-ups drain battery
- iOS may throttle repeated wakes
- Consider batching operations
What network requirements does push wake have?
- Push requires network on phone
- If phone is in airplane mode, push won’t work
Troubleshooting
Push Wake Not Working
- Check notification permissions
- Check Background App Refresh is enabled
- Ensure app wasn’t force-quit
- Verify device has network
# Check the current connection status of all registered devices
cmdop machines
# HOSTNAME STATUS
# marks-iphone suspended # Can be woken
# marks-iphone offline # No network or force-quitSlow Wake Times
Push delivery depends on:
- Network conditions
- iOS power management
- APNS server load
Typical times:
- Wi-Fi + charging: 2-5 seconds
- Cellular + battery: 5-15 seconds
- Low power mode: 10-30 seconds
Rate Limiting
iOS limits background execution:
- Don’t wake more than once per minute
- Batch operations when possible
How do I set up scheduled sync with push wake?
import asyncio
from datetime import datetime
async def scheduled_sync():
"""Sync files every hour using push wake to reach the device."""
while True:
try:
# Wake the device and list remote files for syncing
remote = await client.files.list("marks-iphone", "/Documents")
# Download each file that matches the backup criteria
for file in remote:
if should_backup(file):
await client.files.download(
"marks-iphone",
file.path,
f"./backup/{file.name}"
)
print(f"Sync completed at {datetime.now()}")
except Exception as e:
print(f"Sync failed: {e}")
# Wait 1 hour before the next sync cycle
await asyncio.sleep(3600)
asyncio.run(scheduled_sync())Next
- File Access — iOS file operations
- iOS Agent — Complete iOS guide