Giter VIP home page Giter VIP logo

smart-app-banner's Introduction

Smart App Banner

Lightweight smart app banner with no jQuery (or any other framework) requirement.

Based on 'jQuery Smart Banner' by Arnold Daniels [email protected] https://github.com/jasny/jquery.smartbanner

Difference

  • Standalone (no frameworks required)
  • Different icons/price for iOS and Android
  • Available as npm-module

Installation

$ npm install --save smart-app-banner

Usage

<html>
  <head>
    <title>MyPage</title>

    <meta name="apple-itunes-app" content="app-id=502838820">
    <meta name="google-play-app" content="app-id=ru.hh.android">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="node_modules/smart-app-banner/dist/smart-app-banner.css" type="text/css" media="screen">
    <link rel="apple-touch-icon" href="apple-touch-icon.png">
    <link rel="android-touch-icon" href="android-icon.png" />
  </head>
  <body>
    ...
    <script src="node_modules/smart-app-banner/dist/smart-app-banner.js"></script>
    <script type="text/javascript">
      new SmartBanner({
          daysHidden: 15,   // days to hide banner after close button is clicked (defaults to 15)
          daysReminder: 90, // days to hide banner after "VIEW" button is clicked (defaults to 90)
          appStoreLanguage: 'us', // language code for the App Store (defaults to user's browser language)
          title: 'MyPage',
          author: 'MyCompany LLC',
          button: 'VIEW',
          store: {
              ios: 'On the App Store',
              android: 'In Google Play',
              windows: 'In Windows store'
          },
          price: {
              ios: 'FREE',
              android: 'FREE',
              windows: 'FREE'
          }
          // , theme: '' // put platform type ('ios', 'android', etc.) here to force single theme on all device
          // , icon: '' // full path to icon image if not using website icon image
          // , force: 'ios' // Uncomment for platform emulation
      });
    </script>
  </body>
</html>

Development

The following commands are available for compiling the project:

Command Result
npm install Installs the required dependencies
npm run build Builds the application JavaScript.

See also

smart-app-banner's People

Contributors

adeyahya avatar d42f avatar dy avatar eirikfro avatar everyonesdesign avatar fabiancernota avatar fliptheweb avatar gableroux avatar giosensation avatar glibin avatar iamstarkov avatar jeffda avatar karunab avatar karunabaral avatar maximevaly avatar sundbry avatar tomek-f avatar xavierdutreilh 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smart-app-banner's Issues

How to make the banner always display?

Hi, I want to make the banner always display to change the style. Currently when I close it or click the button, the banner never display again(maybe within one day). How to change it? Thanks

Error version 1.3.1

In the previous version it showed the banner only for android, now in version 1.3.1 does not show the banner in any version and in the console does not indicate any error.

Use intent on android devices to open app or store

It seems we can use an intent call on android devices to open the app or the store

smart-app-banner does not seem to use this great possibility,

Using the followinf snippet (from http://christopher5106.github.io/mobile/2015/03/26/web-redirection-to-mobile-web-or-app-with-a-modal-box.html)

window.location = 'intent:/'+$("meta[property='al:android:url']").attr("content").split(':/')[1]+'#Intent;package='+$("meta[property='al:android:package']").attr("content")+';scheme='+$("meta[property='al:android:url']").attr("content").split(':/')[0]+';launchFlags=268435456;end;';

As url seem a better way (AND we could use custom Scheme Url to open the app in the appropriate page)

thanks

Does not display smart banner for Chrome on iOS 6+

The logic currently hides the banner for anything on iOS 6+. However a user may be using a browser other than Safari, such as Chrome and will not see the smart banner. Ideally this library would only hide if also using Safari.

Uncaught TypeError: Cannot read property 'appendChild' of null

I get the error : Uncaught TypeError: Cannot read property 'appendChild' of null

Smartbanner.js line: 189 "document.body.appendChild(sb);"

But "sb" does get declared a few lines higher up "var sb = document.createElement('div');"

Any idea what might be the issue?

Need Array.prototype.forEach for IE8

smartbanner.js

Array.prototype.forEach = function(callback, thisObj) {
for (var i = 0,len = this.length; i < len; i++)
callback.call(thisObj, this[i], i, this);
};

Feature Request: add param to constructor to show/hide on construction.

Thanks for a great plugin! Helped solved a need to show a custom banner in our app. When the application boots, it create's the banner, but will only show it under a certain screen. It would be really helpful to be able to pass in an option or a paramater to not call show on construction. Showing could be the default behavior still, so this change wouldn't break the existing API. Could I create a PR for this?

Hiding in app webview?

Is there any built-in way to hide the banner when the page is loaded through a native app using webview?

Add option to disable native iOS banner but keep separate styling on different platforms

Hi,

Is there an option (or can it be implemented) so that the native iOS banner can be disabled and keep the different styling on the banners on each platform? I'm aware there is a "force" and "theme" option but this forces iOS or Android styles on both whereas I want the plugin banner to display with iOS styles on iOS and Android styles on Android.

The reason why I am asking is partly to get around the issue with the native iOS banner displaying in addition to the plugin banner. Assuming this issue got resolved, one might prefer to display the native banner on iOS however the plugin banner allows flexibility in defining the content of the banner whereas the native one does not.

Hope to hear your thoughts on this soon!

Thanks

Smart App Banner not showed up on iOS

I used the following config:

new SmartBanner({
    daysHidden: 15,   // days to hide banner after close button is clicked (defaults to 15)
    daysReminder: 90, // days to hide banner after "VIEW" button is clicked (defaults to 90)
    //appStoreLanguage: 'us', // language code for the App Store (defaults to user's browser language)
    title: 'Uala',
    author: 'Uala S.r.l.',
    button: 'Scopri',
    store: {
        ios: 'Sull\'App Store',
        android: 'Su Google Play',
        windows: 'Sul Windows Store'
    },
    price: {
        ios: 'GRATIS',
        android: 'GRATIS',
        windows: 'GRATIS'
    }
    //, force: 'ios' // Uncomment for platform emulation (ios, android, windows)
});

It works only if I force iOS

How do I compile the source?

I tried:

npm install --save smart-app-banner

But got the following error:

npm WARN install Refusing to install smart-app-banner as a dependency of itself

windows phone

Does it actually works with windows phones?

I can see test example with windows phone support, but still don't understand clear picture

Target Android Only?

If I want to only target android and use the native support in Safari for the apple-itunes-app meta tag Is this possible?

I only put in the android options but when viewing on an iPad I still get the banner with 'undefined' strings displaying.

ccjs not found when building package

The build command uses ccjs and fails because this tool is not installed as a dev dependency.

browserify index.js -s SmartBanner | ccjs - > smart-app-banner.js

daysHidden not working

When I click the close button, I see the smartbanner-closed cookie is only a session cookie, not for the default 15 days, even if I explicitly stated it.

Thanks.

BUG smart-app-banner Safari

In the safari is being shown 2 blocks, the native smart banner and the smart banner of the script.
How to solve this problem?

Specify Icon

Is there a way to specify a certain icon to be used in the banner? I would like to have separate Apple touch icons and app icons.

1.3.1 has breaking changes

You moved your css files, which is a very, very big breaking change. You need to bump to 2.0.0 if you're going to move public files people have to reference. Your docs even say to reference the css file like so:

<link rel="stylesheet" href="node_modules/smart-app-banner/smart-app-banner.css" type="text/css" media="screen">

So everybody's been referencing it there, not in dist, so this is a breaking change, not a "patch".

Banner not showing up on Android

Integrated the code into the header.php of my localhost Wordpress site (meta and file links in tag, script code right inside tag). Tested on my iPhone7's Safari browser and banner shows up, but it does not show on Android's Chrome browser. How do I get it to show up on the Android phone?

NPM package?

I get a double banner on IOS safari, the native one and the smart banner one. This should be a bug.

Ps. Does it really make sense to have this as NPM package?
What about if ones need just the source unminified?

Chrome iOS is broken 😭

There is a statement in minified version, which make it to dissapear in chrome ios:

null===a.match(/iPad|iPhone|iPod/i)&&(null!==a.match(/iPad|iPhone|iPod/i) // always false 

It was transformed from strange if in source

else if (userAgent.match(/iPad|iPhone|iPod/i) !== null) { } else if (userAgent.match(/iPad|iPhone|iPod/i) !== null) {

Invalid bower version

We need to update the bower.json to the same version as package.json (1.1.3) and create a release into github otherwise we are unable to select the version with bower.

Banner too small

The banner is not large enough on smart phones, defeating its purpose

How to use it with Angular

Hello, how to use it with Angular 1.x, i tried, but without success, i can't initialize it. Can someone help with that?

Change 'store' and 'price' separator from hyphen

Currently the "separator" between the "store" option and the "price" option is a hardcoded - (hyphen). I think it should be removed entirely so that the user can add their own in the options or change it to an — (em dash).

For example, if you removed it, you could show that the default settings are:

...
store: {
    ios: '— On the App Store',
    android: '— In Google Play'
},
price: {
    ios: 'GET',
    android: 'FREE'
},
...

Thus allowing the user to decide what kind of dash looks best. Thanks for the great plugin!

Issue with menu icon showing on top of banner

I have a responsive website that shows a menu icon in the top left of the screen. When I tested this on my android phone with Google Chrome, the banner shows as expected and above main content but users can't dismiss the banner because of the menu icon. Any ideas?

false catch Android on win8.1 and Spartan

It seems like windows phone 8.1 Update (and spartan) has android in its user agent.
https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx

// Project Spartan for Windows Phone 
Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0

// Internet Explorer for Windows Phone 8.1 Update 
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 520) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537

Does not work on iOS

Hi,
I'm trying to implement this on my site.
When I use force: 'ios', I see the banner like I should, but otherwise no banner is appearing :S

I also get no errors

Is this a known issue, or did I do something wrong?

Thanks!

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.