MobileiOSAndroidFlutterReact Native
Mobile AI Integration: Calling Chinese LLMs in iOS/Android Apps
How to integrate ChinaWHAPI AI capabilities into iOS and Android native apps or cross-platform frameworks (Flutter/React Native).
Mobile Security Considerations
Never hardcode API Keys in apps — they'll be extracted via decompilation. Correct approach: use a backend proxy or server-side signed temporary tokens.
Flutter Integration
import 'package:http/http.dart' as http;
import 'dart:convert';
Future<String> chat(String prompt) async {
final res = await http.post(
Uri.parse('https://chinawhapi.com/v1/chat/completions'),
headers: {
'Authorization': 'Bearer {server_token}', // server-side token
'Content-Type': 'application/json',
},
body: jsonEncode({
'model': 'qwen3.5-flash',
'messages': [{'role': 'user', 'content': prompt}],
}),
);
return jsonDecode(res.body)['choices'][0]['message']['content'];
}React Native Integration
Use the OpenAI SDK (React Native supports it) or call the API directly with fetch. Using a backend proxy is recommended for additional security.
Network Optimization
Mobile networks are unreliable — implement: request timeout (30-60 seconds recommended), auto-retry (up to 2 times), offline queue (store requests when offline, retry when connection restores).