# Demo **Repository Path**: dhar/Demo ## Basic Information - **Project Name**: Demo - **Description**: No description available - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-01-07 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # React Native FBSDK React Native FBSDK is a wrapper around the iOS Facebook SDK and Android Facebook SDK, allowing for Facebook integration in [React Native](https://facebook.github.io/react-native/) apps. Access to native components, from login to sharing, is provided entirely through documented JavaScript modules so you don't have to call a single native function directly. Functionality is provided through one single npm package so you can use it for both platforms without downloading any extra packages. Follow this guide to use react-native-fbsdk in your react-native app. You can also visit https://developers.facebook.com/docs/react-native for tutorials and reference documentation. ## Installation You need to install the sdk with [npm](https://www.npmjs.com/) and configure native Android/iOS project in the react native project. ### 1. Create React Native project First create a React Native project: ```ruby react-native init YourApp ``` ### 2. Install JavaScript packages Install [rnpm](https://github.com/rnpm/rnpm): ```ruby npm install rnpm -g ``` Use rnpm to install and link the react-native-fbsdk package: ```ruby rnpm install react-native-fbsdk ``` ### 3. Configure native projects #### 3.1 Android project Assuming you have [Android Studio](http://developer.android.com/sdk/index.html) installed, open the project with Android Studio. Go to `MainActivity.java` under `app/src/main/java/com//` to complete setup. Note that packages must be imported to use. Add an instance variable of type `CallbackManager` in class. ```java import android.content.Intent; // <--- import import android.os.Bundle; import com.facebook.CallbackManager; import com.facebook.FacebookSdk; import com.facebook.reactnative.androidsdk.FBSDKPackage; public class MainActivity extends ReactActivity { CallbackManager mCallbackManager; //... ``` Register sdk package in method `getPackages()`. ```java @Override protected List getPackages() { mCallbackManager = new CallbackManager.Factory().create(); ReactPackage packages[] = new ReactPackage[]{ new MainReactPackage(), new FBSDKPackage(mCallbackManager), }; return Arrays.asList(packages); } ``` Override `onActivityResult()`. ```java @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mCallbackManager.onActivityResult(requestCode, resultCode, data); } ``` Before you can run the project, follow the [Getting Started Guide](https://developers.facebook.com/docs/android/getting-started/) for Facebook Android SDK to set up a Facebook app. You can skip the build.gradle changes since that's taken care of by the rnpm link step above, but ***make sure*** you follow the rest of the steps such as calling `FacebookSdk.sdkInitialize` and updating `strings.xml` and `AndroidManifest.xml`. Note that react-native project doesn't have the Application class, so you'll need to create an implementation of the Application class yourself. #### 3.2 iOS project The react-native-fbsdk has been linked by rnpm, the next step will be downloading and linking the native Facebook SDK for iOS. Make sure you have the latest [Xcode](https://developer.apple.com/xcode/) installed. Open the .xcodeproj in Xcode found in the `ios` subfolder from your project's root directory. Now, follow ***all the steps*** in the [Getting Started Guide](https://developers.facebook.com/docs/ios/getting-started/) for Facebook SDK for iOS. Along with `FBSDKCoreKit.framework`, don't forget to import `FBSDKShareKit.framework` and `FBSDKLoginKit.framework` into your Xcode project. #### 3.3 Troubleshooting 1. I cannot run the Android project. - Make sure you added the code snippet in step 3.1. - Make sure you set up a Facebook app and updated the `AndroidManifest.xml` and `res/values/strings.xml` with Facebook app settings. 2. I get a build error stating that one of the Facebook SDK files was not found -- eg. `FBSDKLoginKit/FBSDKLoginKit.h file not found`. - Make sure that the Facebook SDK frameworks are installed in `~/Documents/FacebookSDK`. - Make sure that `FBSDK[Core, Login, Share]Kit.framework` show up in the **Link Binary with Libraries** section of your build target's **Build Phases**. - Make sure that `~/Documents/FacebookSDK` is in the **Framework Search Path** of your build target's **Build Settings**. 3. I get build errors like `Warning: Native component for "RCTFBLikeView" does not exist`: - Make sure that `libRCTFBSDK.a` shows up in the **Link Binary with Libraries** section of your build target's **Build Phases**. ## Usage ### [Login](https://developers.facebook.com/docs/facebook-login) #### Login Button + Access Token ```js const FBSDK = require('react-native-fbsdk'); const { LoginButton, AccessToken } = FBSDK; var Login = React.createClass({ render: function() { return ( { if (error) { alert("login has error: " + result.error); } else if (result.isCancelled) { alert("login is cancelled."); } else { AccessToken.getCurrentAccessToken().then( (data) => { alert(data.accessToken.toString()) } ) } } } onLogoutFinished={() => alert("logout.")}/> ); } }); ``` #### Requesting additional permissions with Login Manager You can also use the Login Manager with custom UI to perform Login. ```js const FBSDK = require('react-native-fbsdk'); const { LoginManager, } = FBSDK; // ... // Attempt a login using the Facebook login dialog asking for default permissions. LoginManager.logInWithReadPermissions(['public_profile']).then( function(result) { if (result.isCancelled) { alert('Login cancelled'); } else { alert('Login success with permissions: ' +result.grantedPermissions.toString()); } }, function(error) { alert('Login fail with error: ' + error); } ); ``` ### [Sharing](https://developers.facebook.com/docs/sharing) #### Share dialogs All of the dialogs included are used in a similar way, with differing content types. All content types are defined with [Flow](http://flowtype.org/) Type Annotation in js/models directory. ```js const FBSDK = require('react-native-fbsdk'); const { ShareDialog, } = FBSDK; // ... // Build up a shareable link. const shareLinkContent = { contentType: 'link', contentUrl: "https://facebook.com", contentDescription: 'Wow, check out this great site!', }; // ... // Share the link using the share dialog. shareLinkWithShareDialog() { var tmp = this; ShareDialog.canShow(this.state.shareLinkContent).then( function(canShow) { if (canShow) { return ShareDialog.show(tmp.state.shareLinkContent); } } ).then( function(result) { if (result.isCancelled) { alert('Share cancelled'); } else { alert('Share success with postId: ' + result.postId); } }, function(error) { alert('Share fail with error: ' + error); } ); } ``` #### Share API Your app must have the `publish_actions` permission approved to share through the share API. You should prefer to use the Share Dialogs for an easier and more consistent experience. ```js const FBSDK = require('react-native-fbsdk'); const { ShareApi, } = FBSDK; // ... // Build up a shareable link. const shareLinkContent = { contentType: 'link', contentUrl: "https://facebook.com", contentDescription: 'Wow, check out this great site!', }; // ... // Share using the share API. ShareApi.canShare(this.state.shareLinkContent).then( var tmp = this; function(canShare) { if (canShare) { return ShareApi.share(tmp.state.shareLinkContent, '/me', 'Some message.'); } } ).then( function(result) { alert('Share with ShareApi success.'); }, function(error) { alert('Share with ShareApi failed with error: ' + error); } ); ``` ### [Analytics for Apps](https://developers.facebook.com/docs/app-events) #### App events ```js const FBSDK = require('react-native-fbsdk'); const { AppEventsLogger, } = FBSDK; // ... // Log a $15 purchase. AppEventsLogger.logPurchase(15, 'USD', {'param': 'value'}) ``` ### [Graph API](https://developers.facebook.com/docs/graph-api) #### Graph Requests ```js const FBSDK = require('react-native-fbsdk'); const { GraphRequest, GraphRequestManager, } = FBSDK; // ... //Create response callback. _responseInfoCallback(error: ?Object, result: ?Object) { if (error) { alert('Error fetching data: ' + error.toString()); } else { alert('Success fetching data: ' + result.toString()); } } // Create a graph request asking for user information with a callback to handle the response. const infoRequest = new GraphRequest( '/me', null, this._responseInfoCallback, ); // Start the graph request. new GraphRequestManager().addRequest(infoRequest).start(); ``` ## License See the LICENSE file. ## Platform Policy Developers looking to integrate with the Facebook Platform should familiarize themselves with the [Facebook Platform Policy](https://developers.facebook.com/policy/). Package Control Messages ======================== MarkdownEditing --------------- # MarkdownEditing Markdown plugin for Sublime Text. Provides a decent Markdown color scheme (light and dark) with more __robust__ syntax highlighting and useful Markdown editing features for Sublime Text. 3 flavors are supported: Standard Markdown, __GitHub flavored Markdown__, MultiMarkdown. ![MarkdownEditing][github] [Dark][github 2] and [yellow][github 3] theme available ([additional](#additional-color-themes)). ## Overview * [Features](#features) * [Key Bindings](#key-bindings) * [GFM Specific Features](#gfm-specific-features) * [Commands for Command Palette](#commands-for-command-palette) * [Installation](#installation) * [Configuration](#configuration) * [Tips](#tips) * [Similar Plugins](#similar-plugins) * [Known Bugs](#known-bugs) * [Contributing](#contributing) * [Credits](#credits) * [Donation](#donation) * [License](#license) ## Features * Asterisks and underscores are autopaired and will wrap selected text - If you start an empty pair and hit backspace, both elements are deleted - If you start an empty pair and hit space, the right element is deleted * Backticks are paired * At the end of a list item, pressing Enter will automatically insert the new list item bullet. - Pressing Tab on the blank list item will indent it and switch the list bullet to another one (Order is `*`, `-`, `+` in a cycle). - Pressing Shift Tab on the blank list item will unindent it in the same way as above. - Sequential Tab s or Shift Tab s are supported. - You can disable automatic bullet switching or choose which bullets to be used, in your settings file. - If a list item contains a [GFM task][GFM], pressing Enter at the end of the line will continue with a new blank task. * At the end of a blockquote line, pressing Enter will automatically extend blockquote. * Selecting some text and pressing > will convert it to blockquote. The first and the last line don't have to be fully selected; partial select works, too. * Left bracket pairing is modified to eliminate the selection and leave the cursor at a point where you can insert a `[]` or `()` pair for a link * Displays Markdown headers in the Project Symbol List (Ctrl Shift R). They will start with `#`, so you will know they belong to markdown files at a glance. Also they will be on top of the list because of the presedence of `#`. * ~ wraps selected text with `~~` (strikethrough). * Typing `#` when there's a selection will surround it with `#` to make it a headline. Multiple presses add additional hashes, increasing the level of the header. Once you hit 6 hashes, it will reset to 0 on the next press. The `mde.match_header_hashes` will determine if the `#` are mirrored on both sides or just at the beginning of the line. * Typing return at the end of a line that begins with hashmarks will insert closing hashmarks on the headline. They're not required for Markdown, it's just aesthetics, and you can change the `mde.match_header_hashes` option in your settings to disable. * Setext-style headers can be completed with `Tab`. That is, typing `Tab` on a line containing only `=` or `-` characters will add or remove enough characters to it to match the length of the line above. * New documents will be named automatically based on the first header. ## Key Bindings | OS X | Windows/Linux | Description |------|---------------|------------- | V | CtrlWinV | Creates or pastes the contents of the clipboard as an inline link on selected text. | R | CtrlWinR | Creates or pastes the contents of the clipboard as a reference link. | K | ShiftWinK | Creates or pastes the contents of the clipboard as an inline image on selected text. | B I | CtrlShiftB CtrlShiftI | These are bound to bold and italic. They work both with and without selections. If there is no selection, they will just transform the word under the cursor. These keybindings will unbold/unitalicize selection if it is already bold/italic. | ^1...6 | Ctrl1...6 | These will add the corresponding number of hashmarks for headlines. Works on blank lines and selected text in tandem with the above headline tools. If you select an entire existing headline, the current hashmarks will be removed and replaced with the header level you requested. This command respects the `mde.match_header_hashes` preference setting. | 6 | AltShift6 | Inserts a footnote. | ^S | CtrlAltS | Organizes references and footnotes. ## GFM Specific Features Underscores in words doesn't mess with bold or italic style: ![underscore-in-words][github 5] Fenced code blocks gets syntax highlighting inside: ![fenced-code-block][github 6] Keyboard shortcuts gets highlighted like in GitHub: ![keyboard-shortcut][github 7] Strikethrough is supported: ![strikethrough][github 8] ## Commands for Command Palette ### Fix Underlined Headers Adjusts every setext-style header to add or remove `=` or `-` characters as needed to match the lengths of their header text. ### Convert Underlined Headers to ATX Converts every setext-style header into an ATX style header. If something is selected only the headers in the selections will be converted, otherwise the conversion will be applied to the whole view. ### Add Missing Link Labels Scans document for referenced link usages (`[some link][some_ref]` and `[some link][]`) and checks if they are all defined. If there are undefined link references, command will automatically create their definition snippet at the bottom of the file. ### Markdown Lint Performs lint on current Markdown file. See [lint rules](lint_docs/RULES.md). Some of the linting rules are customizable via user settings file. ### Switch List Bullet Type Switches the highlighted list between numbered and bulleted style. ## Installation > __Important Note About Installation__ > > Are you getting this error after installation: _**Error loading syntax file** "Packages/Markdown/Markdown.tmLanguage": Unable to open Packages/Markdown/Markdown.tmLanguage_? This is caused by open markdown files at the install time. You have to __manually change their syntax to your newly installed Markdown syntax__. Read the below paragraph for more details on this. _Note_: Sublime text has a native tiny package for Markdown. However, when MarkdownEditing is enabled, native package causes some conflicts. For this reason, MarkdownEditing will automatically disable it. Since it doesn't bring anything new over MarkdownEditing, this is not a loss. But remember, when you disable MarkdownEditing, you have to reenable the native one manually (if you want). If you are using Sublime Text 2, you have to disable the native package _manually_. To do that, add `Markdown` to your `ignored_packages` list in ST user settings: "ignored_packages": [..., "Markdown"], ### Package Control The preferred method of installation is via [Sublime Package Control][wbond]. 1. [Install Sublime Package Control][wbond 2] 2. From inside Sublime Text, open Package Control's Command Pallet: CTRL SHIFT P (Windows, Linux) or CMD SHIFT P on Mac. 3. Type `install package` and hit Return. A list of available packages will be displayed. 4. Type `MarkdownEditing` and hit Return. The package will be downloaded to the appropriate directory. 5. Restart Sublime Text to complete installation. Open a Markdown file and this custom theme. The features listed above should now be available. ### Manual Installation 1. Download or clone this repository to a directory `MarkdownEditing` in the Sublime Text Packages directory for your platform: * Mac: `git clone https://github.com/SublimeText-Markdown/MarkdownEditing.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/MarkdownEditing` * Windows: `git clone https://github.com/SublimeText-Markdown/MarkdownEditing.git %APPDATA%\Sublime/ Text/ 2/\MarkdownEditing` * Linux: `git clone https://github.com/SublimeText-Markdown/MarkdownEditing.git ~/.Sublime\ Text\ 2/Packages/MarkdownEditing` 2. Restart Sublime Text to complete installation. Open a Markdown file and this custom theme. The features listed above should now be available. ## Configuration The plugin contains 3 different Markdown flavors: Standard Markdown, GitHub flavored Markdown, MultiMarkdown. Default is GitHub flavored Markdown. If you want to set another one as default, open a Markdown file and select your flavor from the menu: `View > Syntax > Open all with current extension as`. You're done. You may want to have a look at the default settings files. They are located at: Packages/MarkdownEditing/Markdown.sublime-settings [GitHub flavored Markdown] Packages/MarkdownEditing/Markdown (Standard).sublime-settings Packages/MarkdownEditing/MultiMarkdown.sublime-settings If you want to override any of the default settings, you can open the appropriate user settings file using the `Preferences > Package Settings > Markdown Editing` menu. Each flavor has a different settings file. Bold and italic markers are configurable through ST shell variables. You can use `Preferences > Package Settings > Markdown Editing` menu to see the default settings file. In order to override it, copy & paste its content into the user settings file (`Packages/User/Bold and Italic Markers.tmPreferences`) from the menu and make your edits. It is pretty straightforward. In order to activate the dark or the yellow theme, put one of these lines to your user settings file of the flavor (`Packages/User/[flavor].sublime-settings`): "color_scheme": "Packages/MarkdownEditing/MarkdownEditor-Dark.tmTheme", "color_scheme": "Packages/MarkdownEditing/MarkdownEditor-Yellow.tmTheme", If you want to go with your already existing theme, you can reenable it with the same method as above. Keep in mind that, that theme may not cover all the parts of the Markdown syntax that this plugin defines. ### Additional color themes: - [Blackboard theme][linkBlackboardTheme] by [@mdesantis][mdesantis] By default, when you install the plugin, files with these extensions will be assigned to Markdown syntax: "md", "txt", "mdown", "markdown", "markdn". If you want to prevent any of these extensions to be opened as Markdown, follow these steps: 1. Click on the language menu at bottom right 2. Select "Open all with current extension as" 3. Choose your preferred syntax for that extension ## Tips We are maintaining a [tips section][tips] in our [Wiki][]. Jump there to learn from others or share your experiences with others. ## Similar Plugins * [Knockdown][] Knockdown offers useful Markdown features and a custom Markdown theme. All of its unique features except its theme are ported to MarkdownEditing and some of them are actually improved further in MarkdownEditing. * [Sublime Markdown Extended][] * [SmartMarkdown][] ## Known Bugs * Setext-style headers (`===` and `---`) do not show up in the symbol list. This is due to a Sublime Text limitation (see [#158][]). However, we are able to put a placeholder to indicate the existence of the header. We encourage you to use Atx-style headers (`#`). * Installing for the first time while having markdown files opened may cause MarkdownEditing to behave unexpectedly on those files. Close and reopen those files to fix it. ## Contributing See `CONTRIBUTING.md` file. ## Credits MarkdownEditing was originally created by [Brett Terpstra][brettterpstra] and has become a community project with the goal of consolidating the best features from the varied collection of Markdown packages for Sublime Text. Current development is headed up by [Ali Ayas][github 9] and [Felix Hao][github 10]. Related blog posts from Brett: * http://brettterpstra.com/2012/05/17/markdown-editing-for-sublime-text-2-humble-beginnings/ * http://brettterpstra.com/2013/11/23/markdownediting-for-sublime-text-updates/ This plugin contains portions of code from [Knockdown][]. Footnote commands were submitted by [J. Nicholas Geist][github 4] and originated at [geekabouttown][geekabouttown]. ## Donation You can support [contributors](https://github.com/SublimeText-Markdown/MarkdownEditing/graphs/contributors) of this project individually. Every contributor is welcomed to add his/her line below with any content. Ordering shall be alphabetically by GitHub username. * [@felixhao28][github 10]: [paypal] * [@maliayas][github 9]: [paypal] ![donation received](http://maliayas.com/business/donation/badge.php?project=markdown_editing) ## License MarkdownEditing is released under the [MIT License][opensource]. [TableEditor]: https://github.com/vkocubinsky/SublimeTableEditor [Knockdown]: https://github.com/aziz/knockdown/ [Sublime Markdown Extended]: https://github.com/jonschlinkert/sublime-markdown-extended [SmartMarkdown]: https://github.com/demon386/SmartMarkdown [Typewriter]: https://github.com/alehandrof/Typewriter [OpenUrl]: https://github.com/noahcoad/open-url [brettterpstra]: http://brettterpstra.com [geekabouttown]: http://geekabouttown.com/posts/sublime-text-2-markdown-footnote-goodness [github]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/light.png [github 2]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/dark.png [github 3]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/yellow.png [github 4]: https://github.com/jngeist [github 5]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/underscore-in-words.png [github 6]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/fenced-code-block.png [github 7]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/keyboard-shortcut.png [github 8]: https://raw.github.com/SublimeText-Markdown/MarkdownEditing/master/screenshots/strikethrough.png [github 9]: https://github.com/maliayas [github 10]: https://github.com/felixhao28 [opensource]: http://www.opensource.org/licenses/MIT [wbond]: http://wbond.net/sublime_packages/package_control [wbond 2]: http://wbond.net/sublime_packages/package_control/installation [FullScreenStatus]: https://github.com/maliayas/SublimeText_FullScreenStatus [macstories]: http://www.macstories.net/roundups/sublime-text-2-and-markdown-tips-tricks-and-links/ [tips]: https://github.com/SublimeText-Markdown/MarkdownEditing/wiki/Tips [Wiki]: https://github.com/SublimeText-Markdown/MarkdownEditing/wiki [GFM]: https://help.github.com/articles/github-flavored-markdown [#158]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues/158 [linkBlackboardTheme]: https://github.com/mdesantis/MarkdownEditing/blob/blackboard-theme/MarkdownEditor-Blackboard.tmTheme [mdesantis]: https://github.com/mdesantis