Мне нужно создать конечную точку платформы в AWS для push-уведомлений SNS.
Чтобы зарегистрировать устройство для получения push-уведомлений, мне нужно отправить идентификатор устройства в SNS, я не использую когнито, я хочу загрузить токен с помощью AWS SDK с телефона:
AWSSNSCreatePlatformEndpointInput
когда я пытаюсь зарегистрироваться с:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{
NSLog(@"deviceToken: %@", deviceToken);
/* This is the code to actually register the device with Amazon SNS Mobile Push based on the token received */
NSString * myArn = @"arn:aws:sns:us-east-1:123456789123:app/APNS_SANDBOX/AmazonMobilePushExample";
NSLog( @"Submit the device token [%@] to SNS to receive notifications.", [self deviceTokenAsString:deviceToken] );
AWSSNSCreatePlatformEndpointInput *platformEndpointRequest = [AWSSNSCreatePlatformEndpointInput new];
platformEndpointRequest.customUserData = @"MyUserID;iPhone5";
platformEndpointRequest.token = [self deviceTokenAsString:deviceToken];
platformEndpointRequest.platformApplicationArn = myArn;
//THIS LINE CRASHING
AWSSNS *snsManager = [AWSSNS defaultSNS];
// [snsManager createPlatformEndpoint:platformEndpointRequest];
}
Но я получаю сообщение об ошибке:
'The service configuration is
nil
. You need to configureawsconfiguration.json
,Info.plist
or setdefaultServiceConfiguration
before using this method.'
Итак, как настроить любой из моих списков моего метода напрямую без когнито?
Ваше здоровье
Что требовалось, так это установить
AWSServiceManager defaultServiceManager
как показано ниже:
- (void)awsStartWithDeviceToken:(NSData *)deviceToken {
// Set the log level
[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;
// Login
AWSStaticCredentialsProvider *credentialsProvider = [[AWSStaticCredentialsProvider alloc]
initWithAccessKey:@"AKIAIxxxYYYA"
secretKey:@"Tx0vhKv1xMaaabbbbccccM5+3R9lEitw2Hzw"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc]
initWithRegion:AWSRegionAPSoutheast2
credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
// Create SNS Client
AWSSNS *snsManager = [AWSSNS defaultSNS];
/* This is the code to actually register the device with Amazon SNS Mobile Push based on the token received. */
AWSSNSCreatePlatformEndpointInput* platformEndpointRequest = [AWSSNSCreatePlatformEndpointInput new];
platformEndpointRequest.customUserData = @"kUniqueID"; // It could be anything.
platformEndpointRequest.token = [self deviceTokenAsString:deviceToken]; // Device Token No for APNS
platformEndpointRequest.platformApplicationArn = @"arn:aws:sns:ap-southeast-2:86434343191:app/APNS_SANDBOX/ios_lambada";
[snsManager createPlatformEndpoint:platformEndpointRequest completionHandler:^(AWSSNSCreateEndpointResponse * _Nullable response, NSError * _Nullable error) {
NSLog(@"errore : %@", error);
}];
}