Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added method to retrieve APNSToken #100

Merged
merged 1 commit into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ios/FirebasePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- (void)verifyPhoneNumber:(CDVInvokedUrlCommand*)command;
- (void)getId:(CDVInvokedUrlCommand*)command;
- (void)getToken:(CDVInvokedUrlCommand*)command;
- (void)getDeviceToken:(CDVInvokedUrlCommand*)command;
- (void)grantPermission:(CDVInvokedUrlCommand*)command;
- (void)hasPermission:(CDVInvokedUrlCommand*)command;
- (void)setBadgeNumber:(CDVInvokedUrlCommand*)command;
Expand Down
13 changes: 13 additions & 0 deletions src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ - (void)getToken:(CDVInvokedUrlCommand *)command {
}
}

- (void)getDeviceToken:(CDVInvokedUrlCommand *)command {
NSData* apnsToken = [FIRMessaging messaging].APNSToken;
CDVPluginResult *pluginResult;
if (apnsToken) {
NSString* hexToken = [[apnsToken.description componentsSeparatedByCharactersInSet:[[NSCharacterSet alphanumericCharacterSet]invertedSet]]componentsJoinedByString:@""];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:hexToken];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil];
}

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)hasPermission:(CDVInvokedUrlCommand *)command {
@try {
[self _hasPermission:^(BOOL enabled) {
Expand Down
4 changes: 4 additions & 0 deletions www/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ exports.getToken = function (success, error) {
exec(success, error, "FirebasePlugin", "getToken", []);
};

exports.getDeviceToken = function (success, error) {
exec(success, error, "FirebasePlugin", "getDeviceToken", []);
};

exports.onMessageReceived = function (success, error) {
exec(success, error, "FirebasePlugin", "onMessageReceived", []);
};
Expand Down