Git Product home page Git Product logo

react-smartbanner's Introduction

React-SmartBanner

Build Status npm version Coverage Status npm

Rewrite Smart App Banner in React.js.

Demo & Examples

Live demo: patw0929.github.io/react-smartbanner

To build the examples locally, run:

npm install
npm start

or

yarn
yarn start

Installation

The easiest way to use react-smartbanner is to install it from NPM and include it in your own React build process (using Webpack, etc).

You can also use the standalone build by including dist/main.js in your page. If you use this, make sure you have already included React, and it is available as a global variable.

npm install react-smartbanner --save

or

yarn add react-smartbanner

Compatibility

react-smartbanner version React version
4.x.x+ ^16.0.0
3.x.x ^15.0.0

Usage

Remember to add following meta tags in your HTML page: (Use Facebook app as example)

<head>
  <meta name="apple-itunes-app" content="app-id=284882215">
  <meta name="google-play-app" content="app-id=com.facebook.katana">
  <meta name="msApplication-ID" content="82a23635-5bd9-df11-a844-00237de2db9e">
  <meta name="msApplication-PackageFamilyName" content="facebook_9wzdncrfhv5g">
  <link rel="apple-touch-icon" href="icon.png">
  <link rel="android-touch-icon" href="icon.png">
  <link rel="windows-touch-icon" href="icon.png">
</head>

And React-SmartBanner component usage:

import React from 'react';
import ReactDOM from 'react-dom';
import SmartBanner from 'react-smartbanner';
import 'react-smartbanner/dist/main.css';

ReactDOM.render(<SmartBanner title={'Facebook'} />, document.getElementById('content'));

Properties

Please see the Demo Page

Development (src and the build process)

NOTE: The source code for the component is in src. A UMD bundle is also built to dist, which can be included without the need for any build system.

To build, watch and serve the examples (which will also watch the component source), run npm start.

If you want to build to the bundle file to dist/ folder, please run:

npm run build

or

yarn run build

Contributing

To contribute to react-smartbanner, clone this repo locally and commit your code on a separate branch. Please write tests for your code, and run the linter before opening a pull-request:

npm test
npm run lint

or

yarn test
yarn run lint

Based on

Smart App Banner

License

MIT

Copyright (c) 2015-2019 patw.

react-smartbanner's People

Contributors

ardhimas avatar aschleicher2 avatar boorasso avatar davidkwan95 avatar emersonbroga avatar franckmaurin avatar grossmail1 avatar matttarget avatar patw0929 avatar philin-anton avatar poorpaddy avatar quangrau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-smartbanner's Issues

make it possible to show banner on iOS versions > 6

I want to show a different app in the banner depending on the country the user is in. Since it is not possible for me to do this in the backend I have to change the meta tags with JavaScript.

This makes it impossible to use the native iOS banner but since your component ignores newer iOS versions I get no banner at all.

It would be nice if we had an option to allow the banner on newer iOS versions for use cases like mine.

Doesn't bring up appropriate store on Kindle

This module works great on iOS and android however, when a user clicks the link using Silk on their kindle they are directed to the google playstore.

We have added the <meta name="kindle-fire-app" content="app-id=B00JMRGQHI"> tag that worked on our old app using the jquery based library. Is there a specific prop I need to add to make this work with the Amazon store?

Doesn't work on IOS devices

When I try to view the banner when in device mode in chrome devtools, and using an IOS device setting, the banner does not show up. It also doesn't show on actual devices either.

I have seen this on the demo page too for this repo. Any ideas how to get it to work?

Server-Side Rendering

Hello!

Based on #6, i had the same issue(window is not defined). I would like to know if have you plans to do SSR. I would like do prepare some PR. Could be a good idea?

The "language" code in Apple App Store is incorrect

The url for the Apple App Store is NOT https://itunes.apple.com/LANGUAGE_CODE/app/id, it's https://itunes.apple.com/COUNTRY_CODE/app/id.

That means when the browsers language is English the link to the App Store will be https://itunes.apple.com/en/app/id but it should be https://itunes.apple.com/us/app/id, https://itunes.apple.com/gb/app/id or any other country code.

How to implement custom style

Hello developers, I want to add some custom stylesheets. So How can I work on custom style?

I need some help urgently.

I really appreciate any help you can provide.

The code doesn't seem to work on iOS Safari browsers

The code doesn't seem to work on iOS Safari browsers. I am not that conversant with React, so please excuse me if I am making any obvious mistakes. The code is pretty much the example given in the readme. Also, the code works fine on iOS Chrome browser. It doesn't work on Safari. Any thoughts?

Also, what is the right way to pass the'force' property? I tried the following and it throws a type error.

force={'(android,ios)'}

Error in redirection on click of "View"

When I try to get to the store throw the "View" button of the smartbanner (Test on local server & physical iOS & Android devices), the console return this:

image

image

Any ideas?

Bad or partial release

It looks like the dist files didn't get properly generated for v5.0.0. The dist/main.js file shows the old this.props.url and main.css isn't being generated at all.

Double checked clearing both npm & yarn cache and nuked node modules each time.

Add callback to clicking actions?

Can we add callbacks to the user actions (clicking the close/install button)? This allows developers to do something more on their side (e.g. track user actions).

I can send a pr for this

ReferenceError: window is not defined at v5.1.2

I get this error just after updating the package to version 5.1.2!

(function (exports, require, module, __filename, __dirname) { !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):"object"==typeof exports?exports.SmartBanner=t(require("react"),require("prop-types")):e.SmartBanner=t(e.React,e.PropTypes)}(window,function(i,n){return function(i){var n={};function o(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return i[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=i,o.c=n,o.d=function(e,t,i){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);i

ReferenceError: window is not defined
    at Object.<anonymous> (/home/node/node_modules/react-smartbanner/dist/main.js:1:319)
    at Module._compile (module.js:652:30)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/node/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/node/client/index.js:5:1)
    at Module._compile (module.js:652:30)
    at loader (/home/node/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/node/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

More to mention, I'm running a server-side rendering project.

How to deal with a top-fixed nabvbar

Steps to reproduce:

add a position:fixed;top:0;z-index:1000 navigation bar to the page layout (very popular with mobile design)
What happens: the react-smartbanner hides below the navbar instead of pushing it down

What should happen: the react-smartbanner should push the navbar down

Hide after click - to be optional

Hello!
Nowadays when Smartbanner is clicked, it sets a cookie and hide itself until cookie expires or is deleted.

I would add new props hideOnclick with default value true.

Is it worth to send a PR?

Chrome iOS

This checks for iOS 6+, but doesn't check for Safari vs Chrome. So the banner is correctly hidden on newer versions of Safari (in favor of native banners), but I believe Chrome will also be hidden, right? Chrome doesn't support native app banners.

iOS 11 Shows both banners

iOS shows both the native Safari smart banner and react-smartbanner. Not sure of the solution yet but an idea would be to remove the dependency of the meta tags.

Cannot develop or commit.

Hey, I can't develop on your repo. When I do npm install it shows me No matching version found for webpack@beta. Solved this by setting webpack to 3.10.0.

When I want to commit it shows me ./node_modules/pre-commit/hook: line 49: : command not found.

Window is not defined

(function (exports, require, module, __filename, __dirname) { !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):"object"==typeof exports?exports.SmartBanner=n(require("react")):e.SmartBanner=n(e.React)}(this,function(e){return function(e){function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var t={};return n.m=e,n.c=t,n.p="./",n(0)}([function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?e:n}function s(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("S

ReferenceError: window is not defined

I'm getting this error after importing the package into my project. I'm using webpack btw, appreciate if you could help. Thanks.

Nothing gets rendered

I am getting this in the output
<!-- react-empty: 42 -->
Even if I use force for type of devices -

<SmartBanner title={'Facebook'} force={'android'} />

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.