0

Also folgte ich dieser sehr hilfreichen Anleitung https://medium.com/aws-activate-startup-blog/a-guide-to-amazon-simple-notification-service-mobile-push-self-registration-for-ios-a2502e8d5fbd#.99xqlwovh über SNS und Cognito, um mit meiner Anwendung zu arbeiten. Das einzige, was ich tun möchte, ist neue Geräte Token als Endpunkte bei der Installation zu registrieren.Fehler, die Amazon SNS/Cognito dazu gebracht haben, DeviceTokens unter iOS zu registrieren - Objective-C

Ich folgte der Anleitung genau und ich bekomme einige Fehler. Hoffentlich kann mir jemand helfen.

- (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); 
} 

Es Fehler ist hier:

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

Im bekommen "Kein sichtbarer @interface für 'AWSSNS spricht der Wähler 'initWithConfiguration'."

Dies sind meine Header, die in Ordnung sein sollten.

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

Vielen Dank für jede Hilfe im Voraus.

Antwort

0

Diese Linie hat einen Bug:

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

- new ein Äquivalent - alloc zuzüglich - init. Sie rufen zwei init Methoden auf. Es sollte geändert werden:

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

Auch - initWithConfiguration: für eine Weile als veraltet war, und jetzt ist es aus dem SDK entfernt. Sie müssen stattdessen + defaultSNS oder + SNSForKey: verwenden.

Verwandte Themen