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
6 changes: 2 additions & 4 deletions demo-angular/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { AppComponent } from "./app.component";
import { LoginModule } from "./pages/login/login.module";
import { HomeModule } from "./pages/home/home.module";
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";
import { init, LoginBehavior } from "nativescript-facebook";
import { init } from "nativescript-facebook";

application.on(application.launchEvent, function (args) {
init("1771472059772879", LoginBehavior.LoginBehaviorWeb);
init("1771472059772879");
});

@NgModule({
Expand Down
3 changes: 1 addition & 2 deletions demo-vue/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Login from "./components/Login";

import {
init,
LoginBehavior
} from 'nativescript-facebook';

import FacebookPlugin from "nativescript-facebook/vue";
Expand All @@ -13,7 +12,7 @@ Vue.use(FacebookPlugin);
Vue.config.silent = true;

application.on(application.launchEvent, function (args) {
init("1771472059772879", LoginBehavior.LoginBehaviorWeb);
init("1771472059772879");
});

new Vue({
Expand Down
3 changes: 3 additions & 0 deletions demo-vue/e2e/test.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ describe("Facebook tests", async function () {
await driver.wait(1000);
await allFields[0].sendKeys(USERNAME);
} else {
const continueBtn = await driver.findElementByText("Continue");
await continueBtn.click();

const passField = await driver.findElementByClassName(driver.locators.getElementByName("securetextfield"));
await passField.click();
await passField.sendKeys(PASSWORD);
Expand Down
4 changes: 2 additions & 2 deletions demo/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as application from 'tns-core-modules/application';
import { init, LoginBehavior } from "nativescript-facebook";
import { init } from "nativescript-facebook";

application.on(application.launchEvent, function (args) {
init("1771472059772879", LoginBehavior.LoginBehaviorWeb);
init("1771472059772879");
});

application.run({ moduleName: "app-root" });
Expand Down
12 changes: 8 additions & 4 deletions demo/e2e/test.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("Facebook tests", async function () {
console.log("Driver successfully quit");
});

afterEach(async function (){
afterEach(async function () {
if (this.currentTest.state && this.currentTest.state === "failed") {
let png = await driver.logScreenshot(this.currentTest.title);
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
Expand All @@ -52,13 +52,14 @@ describe("Facebook tests", async function () {
});
addContext(this, './' + this.currentTest.title + '.png');
}
})
});

it("should log in via custom button", async function () {
let userNameLabelElement;
if (isAndroid) {
var userNameLabelElement = "[@text='Nativescript User']";
userNameLabelElement = "[@text='Nativescript User']";
} else {
var userNameLabelElement = "[@name='Nativescript User']";
userNameLabelElement = "[@name='Nativescript User']";
}

const facebookButton = await driver.findElementByText("Custom", SearchOptions.contains);
Expand All @@ -81,6 +82,9 @@ describe("Facebook tests", async function () {
await driver.wait(1000);
await allFields[0].sendKeys(USERNAME);
} else {
const continueBtn = await driver.findElementByText("Continue");
await continueBtn.click();

const passField = await driver.findElementByClassName(driver.locators.getElementByName("securetextfield"));
await passField.click();
await passField.sendKeys(PASSWORD);
Expand Down
1 change: 0 additions & 1 deletion src/index.android.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from "./login-manager";
export * from "./ui/login-button";
export * from "./login-event-data";
export * from "./login-behavior";
export * from './share-manager';
export * from "./ui/share-button";
1 change: 0 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ export * from "./login-manager";
export * from "./ui/login-button";
export * from "./login-response";
export * from "./login-event-data";
export * from "./login-behavior";
export * from './share-manager';
export * from "./ui/share-button";
5 changes: 2 additions & 3 deletions src/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as applicationModule from "tns-core-modules/application";
export * from "./ui/login-button";
export * from "./login-manager";
export * from "./login-event-data";
export * from "./login-behavior";
export * from './share-manager';
export * from "./ui/share-button";

Expand All @@ -13,11 +12,11 @@ class BaseDelegate extends UIResponder implements UIApplicationDelegate {
public static ObjCProtocols = [UIApplicationDelegate];

applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary<any, any>): boolean {
return FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application, launchOptions);
return FBSDKApplicationDelegate.sharedInstance.applicationDidFinishLaunchingWithOptions(application, launchOptions);
}

applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation) {
return FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation);
return FBSDKApplicationDelegate.sharedInstance.applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation);
}

applicationDidBecomeActive(application: UIApplication): void {
Expand Down
24 changes: 0 additions & 24 deletions src/login-behavior.d.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/login-behavior.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/login-manager.android.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as application from "tns-core-modules/application";
import { LoginResponse } from './login-response';
import { FacebookAccessToken } from "./facebook-access-token";
import { LoginBehavior } from "./login-behavior";

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

Expand All @@ -15,7 +14,7 @@ export function _registerLogoutCallback(callback: Function) {
onLogoutCallback = callback;
}

export function init(fbId: string, fbLoginBehavior: LoginBehavior = LoginBehavior.LoginBehaviorBrowser) {
export function init(fbId: string) {
com.facebook.FacebookSdk.setAutoLogAppEventsEnabled(true);
setAppId(fbId);
androidApplication = application.android;
Expand Down
4 changes: 1 addition & 3 deletions src/login-manager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ 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";
import { FacebookAccessToken } from "./facebook-access-token";

/**
* 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, fbLoginBehavior?: LoginBehavior): void;
export declare function init(fbId: string): void;
/**
* Request the specified publish permissions.
* @param {string[]} permissions Array of the requested publish permissions.
Expand Down
12 changes: 5 additions & 7 deletions src/login-manager.ios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as applicationModule from "tns-core-modules/application";
import { LoginResponse } from './login-response';
import { LoginBehavior } from './login-behavior';
import { FacebookAccessToken } from "./facebook-access-token";

const LOGIN_PERMISSIONS = ["public_profile", "email"];
Expand All @@ -11,10 +9,10 @@ export let onLogoutCallback;

let loginManager;

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

export function _registerLogoutCallback(callback: Function) {
Expand Down Expand Up @@ -53,7 +51,7 @@ export function _registerLoginCallback(callback: Function) {
}

function setAppId(fbAppId: string) {
FBSDKSettings.setAppID(fbAppId);
FBSDKSettings.appID = fbAppId;
}

export function requestPublishPermissions(permissions: string[], callback: Function) {
Expand All @@ -63,15 +61,15 @@ export function requestPublishPermissions(permissions: string[], callback: Funct

export function requestReadPermissions(permissions: string[], callback: Function) {
_registerLoginCallback(callback);
loginManager.logInWithReadPermissionsHandler(permissions, onLoginCallback);
loginManager.logInWithPermissionsFromViewControllerHandler(permissions, undefined, onLoginCallback);
}

export function login(callback: Function) {
requestReadPermissions(LOGIN_PERMISSIONS, callback);
}

export function getCurrentAccessToken() {
let sdkAccessToken = FBSDKAccessToken.currentAccessToken();
let sdkAccessToken = FBSDKAccessToken.currentAccessToken;
let accessToken = null;

if (sdkAccessToken) {
Expand Down
6 changes: 3 additions & 3 deletions src/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pod 'FBSDKCoreKit', '~> 4.38.0'
pod 'FBSDKLoginKit', '~> 4.38.0'
pod 'FBSDKShareKit', '~> 4.38.0'
pod 'FBSDKCoreKit', '~> 5.0'
pod 'FBSDKLoginKit', '~> 5.0'
pod 'FBSDKShareKit', '~> 5.0'
Loading