@@ -33,40 +33,43 @@ public class RegistrationExample {
33
33
public static void main (String [] args ) {
34
34
final String usage = """
35
35
36
- Usage: <token> <platformApplicationArn>
36
+ Usage: <token> <platformApplicationArn>
37
37
38
- Where:
39
- token - The name of the FIFO topic.\s
40
- platformApplicationArn - The ARN value of platform application. You can get this value from the AWS Management Console.\s
41
- """ ;
38
+ Where:
39
+ token - The device token or registration ID of the mobile device. This is a unique
40
+ identifier provided by the device platform (e.g., Apple Push Notification Service (APNS) for iOS devices, Firebase Cloud Messaging (FCM)
41
+ for Android devices) when the mobile app is registered to receive push notifications.
42
+
43
+ platformApplicationArn - The ARN value of platform application. You can get this value from the AWS Management Console.\s
44
+
45
+ """ ;
42
46
43
47
if (args .length != 2 ) {
44
48
System .out .println (usage );
45
- System . exit ( 1 ) ;
49
+ return ;
46
50
}
47
51
48
52
String token = args [0 ];
49
53
String platformApplicationArn = args [1 ];
50
54
SnsClient snsClient = SnsClient .builder ()
51
- .region (Region .US_EAST_1 )
52
- .build ();
55
+ .region (Region .US_EAST_1 )
56
+ .build ();
53
57
54
58
createEndpoint (snsClient , token , platformApplicationArn );
55
59
}
56
-
57
60
public static void createEndpoint (SnsClient snsClient , String token , String platformApplicationArn ) {
58
61
System .out .println ("Creating platform endpoint with token " + token );
59
62
try {
60
63
CreatePlatformEndpointRequest endpointRequest = CreatePlatformEndpointRequest .builder ()
61
- .token (token )
62
- .platformApplicationArn (platformApplicationArn )
63
- .build ();
64
+ .token (token )
65
+ .platformApplicationArn (platformApplicationArn )
66
+ .build ();
64
67
65
68
CreatePlatformEndpointResponse response = snsClient .createPlatformEndpoint (endpointRequest );
66
69
System .out .println ("The ARN of the endpoint is " + response .endpointArn ());
70
+
67
71
} catch (SnsException e ) {
68
72
System .err .println (e .awsErrorDetails ().errorMessage ());
69
- System .exit (1 );
70
73
}
71
74
}
72
75
}
0 commit comments