-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
BugSomething isn't workingSomething isn't working
Description
I'm developing the twilio-verify package for Flutter, but I have limited experience with native development.
When I create a factor without a push token, it succeeds. However, when I try to create a factor with a push token, it fails with an error. On Android SDK, this issue doesn't occur — the factor is always created successfully. I took the requests and their results from the Xcode logs.
Environment:
SDK: 3.0.0
iOS: 18.5
Xcode: 16.3 (16E140)
✅ Creating a factor without a push token – successful
Create push factor for CreateFactorPayload(
friendlyName: "iPhone",
type: TwilioVerifySDK.FactorType.push,
allowIphoneMigration: false,
serviceSid: "VA4bcb...",
identity: "398...",
config: [
"SdkVersion": "3.0.0",
"AppId": "com.tapslabs.twilioVerifyExample",
"NotificationPlatform": "none"
],
binding: [
"Alg": "ES256",
"PublicKey": "MFkwEwYH...."
],
accessToken: "eyJ6aXAiOi...",
metadata: nil
)
Result:
{
"status": "unverified",
"date_updated": "2025-06-24T11:44:51Z",
"friendly_name": "iPhone",
"binding": {
"alg": "ES256",
"public_key": "MFkwEwYH..."
},
"account_sid": "ACebb...",
"factor_type": "push",
"entity_sid": "YEbd92...",
"url": "https://verify.twilio.com/v2/Services/VA4bcbd2.../Entities/398.../Factors/YF036....",
"sid": "YF0368...",
"date_created": "2025-06-24T11:44:51Z",
"service_sid": "VA4bcb...",
"config": {
"notification_platform": "none",
"sdk_version": "3.0.0",
"credential_sid": "CR65f...",
"app_id": "com.tapslabs.twilioVerifyExample",
"notification_token": ""
},
"identity": "398...",
"metadata": null
}
❌ Creating a factor with a push token – failed
Create push factor for CreateFactorPayload(
friendlyName: "iPhone",
type: TwilioVerifySDK.FactorType.push,
allowIphoneMigration: false,
serviceSid: "VA4bcb...",
identity: "398...",
config: [
"NotificationPlatform": "apn",
"AppId": "com.tapslabs.twilioVerifyExample",
"NotificationToken": "cNf4_oNGRaa3AL54hzyvcf:APA91bGulQXg7Qd6LeD5vglj8CC6mAfjMaDCFfsE1bJMcD0rnpeC7sKi0OqZTccvmB0NnsXNL57XuZOPGx-U8TwuBywZnjnpf8XhVEpgZk6ZqYPG7mZKd1k",
"SdkVersion": "3.0.0"
],
binding: [
"Alg": "ES256",
"PublicKey": "MFkwEwYH...."
],
accessToken: "eyJ6aXAi....",
metadata: nil
)
Result:
--> POST https://verify.twilio.com/v2/Services/VA4bcbd.../Entities/398.../Factors
Authorization: Basic dG9rZW46ZXlK...
Accept: application/json
Content-Type: application/x-www-form-urlencoded
User-Agent: twilio_verify_example; iOS; 1.0.0; 1; iOS 18.5; iPhone; TwilioVerify; 3.0.0; 1
Request:
FriendlyName=iPhone
&FactorType=push
&Binding.Alg=ES256
&Binding.PublicKey=MFkwEwYHK...
&Config.NotificationPlatform=apn
&Config.AppId=com.tapslabs.twilioVerifyExample
&Config.NotificationToken=cNf4_oNGRaa3AL54hzyvcf:APA91bGulQXg7Qd6LeD5vglj8CC6mAfjMaDCFfsE1bJMcD0rnpeC7sKi0OqZTccvmB0NnsXNL57XuZOPGx-U8TwuBywZnjnpf8XhVEpgZk6ZqYPG7mZKd1k
&Config.SdkVersion=3.0.0
Response code: 400
Error body:
{
"code": 400,
"message": "Invalid request",
"more_info": "https://www.twilio.com/docs/errors/400",
"status": 400
}
Here is my Swift code:
// Get args from Flutter as an object with primitive types.
guard let factorPayload = getFactorPayload(from: args) else {
result(
FlutterError(
code: "INVALID_ARGUMENTS",
message: "Invalid arguments for creating a factor",
details: nil))
return
}
twilioVerify.createFactor( // twilioVerify - instance of the SDK
withPayload: factorPayload,
success: { factor in
result(factor.toMap()) // pass factor back to Flutter
}
) { error in
self.handleError(error, result: result) // pass error back to Flutter
}private func getFactorPayload(from data: [String: Any]) -> FactorPayload? {
guard let factorTypeString = data["factorType"] as? String,
let factorType = getFactorType(from: factorTypeString)
else {
return nil
}
switch factorType {
case .push:
return PushFactorPayload(
friendlyName: data["friendlyName"] as? String ?? "",
serviceSid: data["serviceSid"] as? String ?? "",
identity: data["identity"] as? String ?? "",
pushToken: data["pushToken"] as? String,
accessToken: data["accessToken"] as? String ?? "",
metadata: data["metadata"] as? [String: String]
)
@unknown default:
return nil
}
}Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working