Hey,
I know, Push Notification can be so annoying problem for iOS developers. However, OneSignal makes your life easy to sending notifications by using web interface of OneSignal. The installing process is a little bit hard, so, I have written here to make your life easier!
-
Go to onesignal.com
- Login and click the "Create a new app"
- Select "Apple iOS (APNS)"
-
Open new tab, go to onesignal.com/provisionator
- Click Get Started
- Login with your Apple Developer Account
- Select your app that you want to use push notification, click Generate
- Click Download .p12 File and copy the password
-
Turn back to the onesignal.com's tab
- Select the file that you have just downloaded
- Paste the password to the related input, click Save
- Select Native iOS, then copy Your App ID
(like: 5eb5a37e-b458-11e3-ac11-000c2940e62c)
-
You can close the web browser
-
Open the terminal (hint: you can push CMD + Space and write terminal...)
- Write,
cd
and drag drop the your app folder to the terminal, press enter - It has to seem like this:
cd /Users/***/Desktop/XcodeApps/***\ ***
- Write,
pod init
, then press enter - Write,
open Podfile
, then press enter - Write between
do
-and
,pod 'OneSignal'
to the file that did opened and save it - Write,
pod install
, then press enter
- Write,
-
Then open your project with clicking example.xcworkspace
- Open Capabilities tab, Push capability: switch on
- Background Capability: switch on
- In the Background Capability, remote push notification: switch on
-
Then, edit your AppDelegate.swift like above:
import OneSignal
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//Add this line. Replace '5eb5a37e-b458-11e3-ac11-000c2940e62c' with your OneSignal App ID (you have just copied.)
OneSignal.initWithLaunchOptions(launchOptions, appId: "5eb5a37e-b458-11e3-ac11-000c2940e62c")
return true
}