If you are using a cross-platform framework, your code handles both conditionally.
constregisterWithPushblitz=async(token, platform)=>{// 'token' is your FCM or APNS token// 'platform' should be 'ios' or 'android'try{const response =awaitfetch('https://api.pushblitz.com/subscribe',{method:'POST',headers:{'Content-Type':'application/json','X-Channel-ID':'123e4567-e89b-12d3-a456-426614174000',},body:JSON.stringify({platform: platform,provider_token: token,}),});const data =await response.json();console.log('Pushblitz registration:', data);}catch(error){console.error('Error registering to Pushblitz:', error);}};
Flutter (Dart)
In Flutter, after obtaining the device token via firebase_messaging or apns, you can send it to Pushblitz using the standard http package.
import'dart:convert';import'package:http/http.dart'as http;Future<void>registerWithPushblitz(String token,String platform)async{// 'token' is your FCM or APNS token// 'platform' should be 'ios' or 'android'final url =Uri.parse('https://api.pushblitz.com/subscribe');try{final response =await http.post( url, headers:{'Content-Type':'application/json','X-Channel-ID':'123e4567-e89b-12d3-a456-426614174000',}, body:jsonEncode({'platform': platform,'provider_token': token,}),);if(response.statusCode ==200|| response.statusCode ==201){print('Pushblitz registration successful: ${response.body}');}else{print('Pushblitz registration failed: ${response.statusCode} - ${response.body}');}}catch(e){print('Error registering to Pushblitz: $e');}}