Coder Social home page Coder Social logo

ios-firebase-push's Introduction

iOS Push Notification using FCM

  • Xcode 8.3
  • Tested and works in iOS 9 and iOS 10

What's this?

Code example for iOS using Firebase Cloud Messaging (FCM). In addition, we don't care about generated token since this code will utilize Send Message to Topics.

This is very useful when we need to separate notification based on topics or group. Also, easier to manage user subsription.

Really don't need the token?

Yes, it is handled by firebase (swizzling method). Therefore, any apps that subscribe to certain topic will surely get the notification (if server send to that topic). Easy right.

Show me the iOS code..

The AppDelegate here is created based on guide on FCM site

How to test?

Firstly, you must follow steps to setup on firebase as stated on their site

In my example, initially, we are subsribed to "general" topic or you can specify your own topic. Try use postman with below HTTP POST request.

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{
  "to" : /topics/general",
  "priority" : "high",
  "notification" : {
    "body" : "This is a Firebase Cloud Messaging Topic Message!",
    "title" : "FCM Message",
  }
}

Another way, we can test from firebase console.

  • Go to Console
  • Select "Notifications" on the left sidebar
  • Click on "NEW MESSAGE" button and you will get below form

License

Licensed under the MIT license

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.