Skip to content
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
3 changes: 1 addition & 2 deletions demo-angular/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { NativeScriptFacebookModule } from "nativescript-facebook/angular";
import * as application from 'tns-core-modules/application';
import { routes } from "./app.routing";
import { NavigationService } from "./services/navigation.service";

let nsFacebook = require('nativescript-facebook');
import * as nsFacebook from "nativescript-facebook";

application.on(application.launchEvent, function (args) {
nsFacebook.init("1771472059772879");
Expand Down
2 changes: 1 addition & 1 deletion src/index.android.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./login-manager"},{"from":"./login-button"},{"from":"./login-event-data"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./login-manager"},{"from":"./login-button"},{"from":"./login-event-data"}]}]
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./login-manager"},{"from":"./login-button"},{"from":"./login-event-data"},{"from":"./login-behavior"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./login-manager"},{"from":"./login-button"},{"from":"./login-event-data"},{"from":"./login-behavior"}]}]
3 changes: 2 additions & 1 deletion src/index.android.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./login-manager";
export * from "./login-button";
export * from "./login-event-data";
export * from "./login-event-data";
export * from "./login-behavior";
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./login-manager";
export * from "./login-button";
export * from "./login-response";
export * from "./login-event-data";
export * from "./login-behavior";
2 changes: 1 addition & 1 deletion src/index.ios.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./login-button"},{"from":"./login-manager"},{"from":"./login-event-data"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./login-button"},{"from":"./login-manager"},{"from":"./login-event-data"}]}]
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./login-button"},{"from":"./login-manager"},{"from":"./login-event-data"},{"from":"./login-behavior"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./login-button"},{"from":"./login-manager"},{"from":"./login-event-data"},{"from":"./login-behavior"}]}]
3 changes: 2 additions & 1 deletion src/index.ios.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as applicationModule from "tns-core-modules/application";
export * from "./login-button";
export * from "./login-button";
export * from "./login-manager";
export * from "./login-event-data";
export * from "./login-behavior";

declare class UIResponder { }
declare class NSDictionary { }
Expand Down
24 changes: 24 additions & 0 deletions src/login-behavior.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export declare enum LoginBehavior {
/**
This is the default behavior, and indicates logging in through the native
Facebook app may be used. The SDK may still use Safari instead.
*/
LoginBehaviorNative = 0,
/**
Attempts log in through the Safari or SFSafariViewController, if available.
*/
LoginBehaviorBrowser = 1,
/**
Attempts log in through the Facebook account currently signed in through
the device Settings.
@note If the account is not available to the app (either not configured by user or
as determined by the SDK) this behavior falls back to \c LoginBehaviorNative.
*/
LoginBehaviorSystemAccount = 2,
/**
Attempts log in through a modal \c UIWebView pop up
@note This behavior is only available to certain types of apps. Please check the Facebook
Platform Policy to verify your app meets the restrictions.
*/
LoginBehaviorWeb = 3,
}
1 change: 1 addition & 0 deletions src/login-behavior.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"__symbolic":"module","version":3,"metadata":{"LoginBehavior":{"LoginBehaviorNative":0,"LoginBehaviorBrowser":1,"LoginBehaviorSystemAccount":2,"LoginBehaviorWeb":3}}},{"__symbolic":"module","version":1,"metadata":{"LoginBehavior":{"LoginBehaviorNative":0,"LoginBehaviorBrowser":1,"LoginBehaviorSystemAccount":2,"LoginBehaviorWeb":3}}}]
6 changes: 6 additions & 0 deletions src/login-behavior.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum LoginBehavior {
LoginBehaviorNative = 0,
LoginBehaviorBrowser = 1,
LoginBehaviorSystemAccount = 2,
LoginBehaviorWeb = 3,
}
4 changes: 3 additions & 1 deletion src/login-manager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ export declare function _registerLoginCallback(callback: Function): void;
export declare function _registerLogoutCallback(callback: Function): void;
export declare let onLoginCallback: Function;
export declare let onLogoutCallback: Function;
import { LoginBehavior } from "./login-behavior";

/**
* Sets the Facebook application Id for the current app and init the native facebook sdk.
* @param {string} fbAppId the application Id
* @param {LoginBehavior} fbLoginBehavior (iOS only) specifies the login behavior, default value: LoginBehavior.FBSDKLoginBehaviorSystemAccount
*/
export declare function init(fbId: string): void;
export declare function init(fbId: string, fbLoginBehavior?: LoginBehavior): void;
/**
* Request the specified publish permissions.
* @param {string[]} permissions Array of the requested publish permissions.
Expand Down
6 changes: 3 additions & 3 deletions src/login-manager.ios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as applicationModule from "tns-core-modules/application";
import { LoginResponse } from './login-response';
import { LoginBehavior } from './login-behavior';
declare let FBSDKLoginManager: any;
declare let FBSDKSettings: any;
declare class FBSDKLoginManagerLoginResult { isCancelled: boolean; token: any; }
Expand All @@ -9,7 +10,6 @@ declare class UIApplication { }
declare let FBSDKLoginButton: any;
declare class NSDictionary { }

const FB_LOGIN_BEHAVIOUR = 2;
const LOGIN_PERMISSIONS = ["public_profile", "email"];

// TODO: add getter and setter
Expand All @@ -18,10 +18,10 @@ export let onLogoutCallback;

let loginManager;

export function init(fbId: string) {
export function init(fbId: string, fbLoginBehavior: LoginBehavior = LoginBehavior.LoginBehaviorBrowser) {
setAppId(fbId);
loginManager = FBSDKLoginManager.alloc().init();
loginManager.loginBehavior = FB_LOGIN_BEHAVIOUR;
loginManager.loginBehavior = fbLoginBehavior;
}

export function _registerLogoutCallback(callback: Function) {
Expand Down
7 changes: 4 additions & 3 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-facebook",
"version": "2.0.1",
"version": "2.1.0",
"description": "NativeScript plugin, wrapper of native Facebook SDK for Adroid and iOS.",
"nativescript": {
"platforms": {
Expand Down Expand Up @@ -30,7 +30,8 @@
"email": "support@telerik.com",
"url": "http://www.telerik.com"
},
"maintainers": [{
"maintainers": [
{
"name": "angeltsvetkov",
"email": "angel.tsvetkov@progress.com"
},
Expand All @@ -56,6 +57,6 @@
"@angular/compiler-cli": "~4.0.1",
"rxjs": "~5.3.0",
"zone.js": "~0.8.4",
"tslint":"~5.4.3"
"tslint": "~5.4.3"
}
}