0

この非常に役立つガイドhttps://medium.com/aws-activate-startup-blog/a-guide-to-amazon-simple-notification-service-mobile-push-self-registration-for-ios-a2502e8d5fbd#.99xqlwovhに従って、SNSとCognitoを自分のアプリケーションで使用できるようにしました。私がしたいのは、新しいデバイストークンをインストール時のエンドポイントとして登録することだけです。iOS上でDeviceTokensを登録するためのAmazon SNS/Cognitoの取得エラー - Objective-C

ガイドに正確に従っていますが、いくつかのエラーが発生しています。うまくいけば、誰かが私を助けることができます。

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(nonnull NSData *)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.", deviceToken); 

    AWSSNSCreatePlatformEndpointInput *platformEndpointRequest = [AWSSNSCreatePlatformEndpointInput new]; 
    platformEndpointRequest.customUserData = @"MyUserID;iPhone5"; 
    platformEndpointRequest.token = [self deviceTokenAsString:deviceToken]; 
    platformEndpointRequest.platformApplicationArn = myArn; 

    AWSSNS *snsManager = [[AWSSNS new] initWithConfiguration:configuration]; 
    [snsManager createPlatformEndpoint:platformEndpointRequest]; 


    /* End Amazon SNS Mobile Push self registration */ 
    NSLog(@"Device Token is : %@", deviceToken); 
} 

は、エラーがここにあります:

AWSSNS *snsManager = [[AWSSNS new] initWithConfiguration:configuration]; 
    [snsManager createPlatformEndpoint:platformEndpointRequest]; 

Imはなっていない " 'AWSSNS' の目に見える@interfaceするセレクタ 'initWithConfiguration' を宣言します。"

これは私のヘッダーです。これは問題ありません。

#import <AWSCore/AWSCore.h> 
#import <AWSCognito/AWSCognito.h> 
#import <AWSSNS/AWSSNS.h> 

ありがとうございました。私は先に行って、私はチュートリアルからの問題を抱えていたコードを不時着し、このテストプロジェクトhttps://github.com/awslabs/aws-sdk-ios-samples/tree/master/SNS-MobileAnalytics-Sample/Objective-Cから正確にコードを追っ

答えて

0

この行は、バグがあります。

AWSSNS *snsManager = [[AWSSNS new] initWithConfiguration:configuration]; 

- new- allocプラス- initのと同じです。あなたは2つのメソッドを呼び出しています。initそれは次のように変更します。

AWSSNS *snsManager = [[AWSSNS alloc] initWithConfiguration:configuration]; 

また、- initWithConfiguration:はしばらくの間、廃止されていたが、今では、SDKから削除されます。代わりに+ defaultSNSまたは+ SNSForKey:を使用する必要があります。

0

誰がこの問題を持っている場合。これで、デバイストークンを完全に登録して登録しています。

関連する問題