Skip to content

Commit 9cb7058

Browse files
author
Paweł Kania
committed
Readme file
1 parent c8af2c7 commit 9cb7058

4 files changed

Lines changed: 92 additions & 1 deletion

File tree

AppDelegate.png

171 KB
Loading

Breakpoint.png

474 KB
Loading

Code.png

56.6 KB
Loading

README.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,94 @@
11
# PushNotificationSimulation
22

3-
TODO
3+
`PushNotificationSimulation` helps in simulating push notifications in the application during development.
4+
5+
[![Swift 5.0](https://img.shields.io/badge/Swift-5.0-green.svg?style=flat)](https://swift.org/)
6+
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/PushNotificationSimulation.svg)](https://cocoapods.org/pods/PushNotificationSimulation)
7+
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
8+
[![Platform](https://img.shields.io/cocoapods/p/PuzzleMaker.svg)](http://cocoadocs.org/docsets/PuzzleMaker)
9+
[![License](https://img.shields.io/cocoapods/l/PuzzleMaker.svg)](https://github.com/PGSSoft/PuzzleMaker)
10+
11+
## Installation
12+
13+
Using [Cocoapods](https://cocoapods.org/) with Podfile:
14+
15+
```ruby
16+
pod 'PushNotificationSimulation'
17+
```
18+
19+
or using [Carthage](https://github.com/Carthage/Carthage) and add a line to `Cartfile`:
20+
21+
```
22+
github "pwlkania/PushNotificationSimulation"
23+
```
24+
25+
or Swift Package Manager (Xcode 11):
26+
27+
Coming soon!
28+
29+
## Requirements
30+
31+
iOS 11.0
32+
33+
## Initialization
34+
35+
First of all, you need to modify your `AppDelegate.swift` file:
36+
37+
Import `PushNotificationSimulation` framework (if needed):
38+
39+
```swift
40+
import PushNotificationSimulation
41+
```
42+
43+
Implement `PushNotificationSimulation` protocol:
44+
45+
```swift
46+
#if DEBUG
47+
extension AppDelegate: PushNotificationSimulation { }
48+
#endif
49+
```
50+
51+
Implement required property from `PushNotificationSimulation` protocol:
52+
53+
```swift
54+
#if DEBUG
55+
weak var app: UIApplication?
56+
#endif
57+
```
58+
59+
Assign `UIApplication` object to `app` property:
60+
61+
```swift
62+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
63+
// Your code...
64+
65+
#if DEBUG
66+
app = application
67+
#endif
68+
69+
// Your code...
70+
return true
71+
}
72+
```
73+
74+
Your `AppDelegate.swfit` file should look similar to this:
75+
76+
![AppDelegate.png](AppDelegate.png)
77+
78+
## Usage
79+
80+
Using breakpoints with debugger command (suggested approach) - example:
81+
82+
```
83+
e simPush(payload: "{\"aps\":{\"alert\":{\"title\":\"Game Request\",\"subtitle\":\"Five Card Draw\",\"body\":\"Bob wants to play poker\"},\"category\":\"GAME_INVITATION\"},\"gameID\":\"12345678\"}", delay: 3)
84+
```
85+
86+
![Breakpoint.png](Breakpoint.png)
87+
88+
You can also use `simPush(...)` global function directly in the code. However it might cause issues when code is not deactivated in production version of your application. Be careful.
89+
90+
![Code.png](Code.png)
91+
92+
## License
93+
94+
The project is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)