This iOS helloPush sample contains an Swift project that you can use to learn more about the IBM Cloud Push Notification Service.
Before you start, make sure you have the following:
Clone the sample from Github with the following command:
git clone https://github.com/ibm-bluemix-mobile-services/bms-samples-swift-hellopush.git
Navigate to the HelloPush
folder and do the following,
sudo gem install Cocoapods
pod setup
pod install
command to download and install the required dependencies.HelloPush.xcworkspace
. From now on, open the xcworkspace file since it contains all the dependencies and configuration.BMSPushRegister.swift
and add the IBM Cloud push notification service credentialslet cloudRegion = BMSClient.Region.usSouth
let pushAppGUID = "27ee87ce-ed4c-4167-XXXX-XXXXXXX"
let pushClientSecret = "813a430f-XXXXX-XXXXXX-b8e0-XXXXXXXXX"
let userId = "David"
let customeDeviceId = "DavidmobiledeviceId"
let pushVariables = ["username":"David","accountNumber":"3564758697057869"]
Check the getPushOptions()
method in BMSPushRegister.swift
and add the options you need.
For push notifications to work successfully, you must run the helloPush sample on a physical iOS device. You will also need a valid APNs enabled bundle id, provisioning profile, and development certificate.
When you run the application, you will see a single view application with a "Register for Push" Switch. When you click this switch the application will attempt to register the device and application to the Push Notification Service. The app uses an text view to display the registration status (successful or failed).
Now, switch over to the IBM Cloud Push Notifications service and open the service dashboard. Navigate to 'Send Notifications' and send a notification. You could either send a broadcast notification or a notification targeted to iOS platform so that a notification is sent to the helloPush Swift application. When a push notification is received and the application is in the foreground, an alert is displayed showing the notification's content.
Please visit for samples - Github Sample
Video Tutorials Available here - IBM Cloud Push Notifications
======================= Copyright 2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.