@smartface/plugin-firebase
Version:
Smartface Firebase Plugin for Smartface Native Framework
188 lines • 6.82 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var invocation_1 = __importDefault(require("@smartface/native/util/iOS/invocation"));
var Auth_1 = __importDefault(require("../Auth"));
/**
* @classdesc App
* @class
*/
var App = /** @class */ (function () {
function App(nativeObject) {
var _this = this;
/**
* Gets the Auth service for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.auth = function () {
return new Auth_1.default(_this);
};
/**
* Gets the Name for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.getName = function () { return App.ios.native.name(_this.nativeObject); };
/**
* Gets the getApiKey for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.getApiKey = function () { return invocation_1.default.invokeInstanceMethod(_this.ios.native.firOptions, 'APIKey', [], 'NSString'); };
/**
* Gets the getApplicationId for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.getApplicationId = function () { return invocation_1.default.invokeInstanceMethod(_this.ios.native.firOptions, 'googleAppID', [], 'NSString'); };
/**
* Gets the getDatabaseUrl for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.getDatabaseUrl = function () { return invocation_1.default.invokeInstanceMethod(_this.ios.native.firOptions, 'databaseURL', [], 'NSString'); };
/**
* Gets the getGcmSenderId for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.getGcmSenderId = function () { return invocation_1.default.invokeInstanceMethod(_this.ios.native.firOptions, 'GCMSenderID', [], 'NSString'); };
/**
* Gets the getStorageBucket for the current app.
*
* @method
* @android
* @ios
* @since 0.1
*/
this.getStorageBucket = function () { return invocation_1.default.invokeInstanceMethod(_this.ios.native.firOptions, 'storageBucket', [], 'NSString'); };
this.nativeObject = nativeObject;
this.android = {};
this.ios = {};
this.ios.native = {};
this.ios.native.firOptions = App.ios.native.options(this.nativeObject);
/**-
* Delete current app,
*
* @method delete
* @ios
* @since 0.1
*/
this.ios.delete = function (callback) {
function callbackHandler(e) {
if (typeof callback === 'function') {
callback(e.success);
}
}
App.ios.native.deleteApp(_this.nativeObject, callbackHandler);
};
Object.defineProperties(this.ios, {
getBundleId: {
value: function () {
return invocation_1.default.invokeInstanceMethod(this.ios.native.firOptions, 'bundleID', [], 'NSString');
},
enumerable: true,
configurable: true
},
getClientId: {
value: function () {
return invocation_1.default.invokeInstanceMethod(this.ios.native.firOptions, 'clientID', [], 'NSString');
},
enumerable: true,
configurable: true
},
getTrackingId: {
value: function () {
return invocation_1.default.invokeInstanceMethod(this.ios.native.firOptions, 'trackingID', [], 'NSString');
},
enumerable: true,
configurable: true
}
});
App.ios = {};
App.ios.native = {};
}
App.ios = {
native: {
configureWithOptions: function (firOptions) {
// @ts-ignore
var argOptions = new invocation_1.default.Argument({
type: 'NSObject',
value: firOptions
});
// @ts-ignore
invocation_1.default.invokeClassMethod('FIRApp', 'configureWithOptions:', [argOptions]);
},
configureWithNameOptions: function (name, firOptions) {
// @ts-ignore
var argName = new invocation_1.default.Argument({
type: 'NSString',
value: name
});
// @ts-ignore
var argOptions = new invocation_1.default.Argument({
type: 'NSObject',
value: firOptions
});
// @ts-ignore
invocation_1.default.invokeClassMethod('FIRApp', 'configureWithName:options:', [argName, argOptions]);
},
defaultApp: function () {
return invocation_1.default.invokeClassMethod('FIRApp', 'defaultApp', [], 'NSObject');
},
appNamed: function (name) {
// @ts-ignore
var argName = new invocation_1.default.Argument({
type: 'NSString',
value: name
});
return invocation_1.default.invokeClassMethod('FIRApp', 'appNamed:', [argName], 'NSObject');
},
allApps: function () {
return invocation_1.default.invokeClassMethod('FIRApp', 'allApps', [], 'id');
},
name: function (firApp) {
return invocation_1.default.invokeInstanceMethod(firApp, 'name', [], 'NSString');
},
options: function (firApp) {
return invocation_1.default.invokeInstanceMethod(firApp, 'options', [], 'NSObject');
},
deleteApp: function (firApp, callback) {
// @ts-ignore
var argCallback = new invocation_1.default.Argument({
type: 'JSValue',
value: function (e) {
callback(e);
}
});
// @ts-ignore
invocation_1.default.invokeInstanceMethod(firApp, 'deleteAppBridge:', [argCallback]);
}
}
};
return App;
}());
exports.default = App;
module.exports = App;
//# sourceMappingURL=app-iOS.js.map