All Projects → naoufal → React Native Safari View

naoufal / React Native Safari View

A React Native wrapper for Safari View Controller.

Projects that are alternatives of or similar to React Native Safari View

aprenda-swift
Uma lista de conteúdos para você aprender Swift
Stars: ✭ 429 (-9.68%)
Mutual labels:  apple, safari
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (+439.16%)
Mutual labels:  apple, safari
Ultratabsaver
The open source Tab Manager Extension for Safari.
Stars: ✭ 178 (-62.53%)
Mutual labels:  apple, safari
Webbrowser
iOS浏览器 Web Browser for iOS
Stars: ✭ 332 (-30.11%)
Mutual labels:  apple, safari
Wdt Emoji Bundle
Slack like emoji picker with apple/ios, twitter/twemoji, google, emojione, facebook, messenger emoji support
Stars: ✭ 411 (-13.47%)
Mutual labels:  apple
Apnotic
A Ruby APNs HTTP/2 gem able to provide instant feedback.
Stars: ✭ 360 (-24.21%)
Mutual labels:  apple
Apns4erl
Apple Push Notification Server for Erlang
Stars: ✭ 352 (-25.89%)
Mutual labels:  apple
Macos security
macOS Security Compliance Project
Stars: ✭ 348 (-26.74%)
Mutual labels:  apple
Example Ios Apps
 A curated list of Open Source example iOS apps developed in Swift. An amazing list for people who are beginners and learning ios development and for ios developers who need any example app or feature.
Stars: ✭ 461 (-2.95%)
Mutual labels:  apple
Pwa Bugs
🚔 List of PWA Bugs and workarounds
Stars: ✭ 444 (-6.53%)
Mutual labels:  safari
Xcode Defaults
Awesome and useful Xcode defaults
Stars: ✭ 399 (-16%)
Mutual labels:  apple
Macs Fan Control
Control fans on Apple computers
Stars: ✭ 373 (-21.47%)
Mutual labels:  apple
Cfpropertylist
PHP Implementation of Apple's PList (binary and xml)
Stars: ✭ 423 (-10.95%)
Mutual labels:  apple
Glide
Game engine for making 2d games on iOS, macOS and tvOS, with practical examples and tutorials
Stars: ✭ 353 (-25.68%)
Mutual labels:  apple
Octotree
Browser extension that enhances GitHub code review and exploration. You can download Octotree for your browser from our website.
Stars: ✭ 21,726 (+4473.89%)
Mutual labels:  safari
Xhlaunchad
🔥The screen opening advertising solutions - 开屏广告、启动广告解决方案-支持静态/动态图片广告,mp4视频广告,全屏/半屏广告、兼容iPhone/iPad. 【 Github下载不了/下载慢 可以访问国内下载地址: https://gitee.com/CoderZhuXH/XHLaunchAd】
Stars: ✭ 3,578 (+653.26%)
Mutual labels:  apple
Polyglot
🌏 The missing Safari extension that translates selected text into your native language.
Stars: ✭ 387 (-18.53%)
Mutual labels:  safari
Secure Mobile Development
A Collection of Secure Mobile Development Best Practices
Stars: ✭ 427 (-10.11%)
Mutual labels:  apple
Hackintosh Installer University
Open source tutorial & information collector for hackintosh installation.
Stars: ✭ 3,815 (+703.16%)
Mutual labels:  apple
Osx Abi Macho File Format Reference
Mirror of OS X ABI Mach-O File Format Reference
Stars: ✭ 379 (-20.21%)
Mutual labels:  apple

React Native Safari View

react-native version npm version npm downloads Code Climate

React Native Safari View is a Safari View Controller wrapper for React Native.

react-native-safari-view

Documentation

Install

npm i --save react-native-safari-view

Support

Due to the rapid changes being made in the React Native ecosystem, we are not officially going to support this module on anything but the latest version of React Native. The current supported version is indicated on the React Native badge at the top of this README. If it's out of date, we encourage you to submit a pull request!

Usage

Linking the Library

In order to use Safari View, you must first link the library your project. There's excellent documentation on how to do this in the React Native Docs.

Displaying the Safari View

Once you've linked the library, you'll want to make it available to your app by requiring it:

var SafariView = require('react-native-safari-view');

Displaying the Safari View is as simple as calling:

SafariView.show({
  url: 'https://github.com/naoufal'
});

URL Change Notifications

There isn't an API for retrieving URL changes provided by SFSafariViewController or its delegate in iOS, so there's no way to know where the user is navigating to. However, it is possible to get a notification when the Safari View navigates to an URL scheme specified by your app (e.g. your-app-name://). This is especially useful for implementing callback oriented flows such as in OAuth2 / OpenID Connect.

To get URL notifications for your URL scheme you'll need to:

  1. Register an URL scheme in your Xcode Project
  2. Make sure you've set up Linking in your react-native project.
  3. Listen for URL changes in your react-native code (i.e. Linking.addEventListener('url', eventHandler));

Example

Using Safari View in your app will usually look like this:

import React, { Component } from "react";
import SafariView from "react-native-safari-view";

class YourComponent extends Component {
  constructor(props) {
    super(props);
  }

  _pressHandler() {
    SafariView.isAvailable()
      .then(SafariView.show({
        url: "https://github.com/naoufal"
      }))
      .catch(error => {
        // Fallback WebView code for iOS 8 and earlier
      });
  }

  render() {
    return (
      <View>
        ...
        <Button onPress={this._pressHandler}>
          Show Safari View
        </Button>
      </View>
    );
  }
}

Methods

show(safariOptions)

Displays a Safari View with the provided url.

Arguments

  • safariOptions - An Object containing a url key and optionally a readerMode key, a tintColor, and/or a barTintColor.

safariOptions

  • url - A String containing the url you want to load in the Safari View
  • readerMode - A Boolean indicating to use Safari's Reader Mode if available
  • tintColor - A String containing a hex, rgba or rgba color to use for the browser controls
  • barTintColor - A String containing a hex, rgba or rgba color to use for the background of the browser controls (only available on iOS 10 and higher)
  • fromBottom - A 'Boolean' indicating to open the Safari View from the bottom

Examples

SafariView.show({
  url: "http://facebook.github.io/react/blog/2015/03/26/introducing-react-native.html",
  readerMode: true // optional,
  tintColor: "#000" // optional
  barTintColor: "#fff" // optional
});

isAvailable()

Checks if Safari View is available on the device.

Example

SafariView.isAvailable()
  .then(available => {
    console.log("SafariView is available.");
  })
  .catch(error => {
    console.log(error);
  });

dismiss()

Dismisses the currently active Safari View.

Example

SafariView.dismiss()

Events

The following events are fired by the Safari View.

onShow

Example

let showSubscription = SafariView.addEventListener(
  "onShow",
  () => {
    StatusBar.setBarStyle("light-content");
  }
);

onDismiss

Example

let dismissSubscription = SafariView.addEventListener(
  "onDismiss",
  () => {
    StatusBar.setBarStyle("default");
  }
);

License

Copyright (c) 2015, Naoufal Kadhom

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].