• Stars
    star
    117
  • Rank 299,835 (Top 6 %)
  • Language
    Objective-C
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

模仿 《简书 App》 的效果:在html中跳转到App中的对应页面,并能从App跳转到原来的网址

TestExternalURL

模仿 iPhone App 简述 的效果:在html中跳转到App中的对应页面,并能从App跳转到原来的网址 enter image description here

Let's using standard iOS APIs. No need to use external components.

You must know the exact URL that has the link to your app.That is enough!

These are the steps:

  1. In your app, define a custom URL scheme. In this case let's assume you use the scheme myawesomeapp://. You can do this in your Xcode project by going to the Info section of your target. See below

Defining a custom URL scheme

  1. In your web page you need to handle the two scenarios: app installed / not installed. It is just a matter of detecting if an app responds to the scheme myawesomeapp://.

I will explain the case where your app is already installed.

Let's say the webpage that contains the link is:

http://www.mywebsite.com/mypage.html#mytag

The link you provide in your webpage should pass some parameters to the app and one of these should be the URL that you want the app to return. Following with the example the link could be:

myawesomeapp://?action=my_action_1&sourceurl=http%3A%2F%2Fwww.mywebsite.com%2Fmypage.html%23mytag

Note that the URL you pass as a parameter inside the scheme has to be URL encoded or it won't work properly.

  1. In your app delegate you need to implement the method:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

In this method, parse the URL, decode the query items and pass the sourceURL to the view controller responsible of handling the action prior to calling it. In this case I set a public property in the ViewController that will store the URL.

@property (nonatomic, strong) NSURL *sourceURL;

  1. In the view controller when the user finishes the interaction, you just call:

[[UIApplication sharedApplication] openURL:self.sourceURL];

Because self.sourceURL contains the URL of your webpage, Safari will be launched with the URL. However, because that page is already opened, iOS detects this and re-opens that page.

I have a sample project in my Github page that implements all this.

And to finalize, after you install the sample project in your iPhone, open this stack overflow post from mobile Safari and open my awesome app

Once the app is opened, click on the button and you will return to this stack overflow post.

More Repositories

1

iOSInterviewQuestions

iOS interview questions;iOS面试题集锦(附答案)--学习qq群或 Telegram 群交流 https://github.com/ChenYilong/iOSBlog/issues/21
Swift
9,244
star
2

CYLTabBarController

[EN]It is an iOS UI module library for adding animation to iOS tabbar items and icons with Lottie, and adding a bigger center UITabBar Item. [CN]【中国特色 TabBar】一行代码实现 Lottie 动画TabBar,支持中间带+号的TabBar样式,自带红点角标,支持动态刷新。【iOS13 & Dark Mode & iPhone XS MAX supported】
Swift
6,860
star
3

iOS9AdaptationTips

iOS9适配系列教程(iOS开发学习交流群: https://github.com/ChenYilong/iOSBlog/issues/21)
Objective-C
4,477
star
4

ParseSourceCodeStudy

Facebook开源的Parse源码分析【系列】
Objective-C
2,876
star
5

CollectionViewClassifyMenu

CollectionView做的两级菜单,可以折叠第二级菜单
Objective-C
1,535
star
6

iOSBlog

微博@iOS程序犭袁 的blog
Objective-C
1,117
star
7

CYLTableViewPlaceHolder

一行代码完成“空TableView占位视图”管理
Objective-C
901
star
8

iOS10AdaptationTips

for iOS10 in [ObjC, Swift, English, 中文] {...}
Objective-C
642
star
9

iOS11AdaptationTips

for iOS11 in [ObjC, Swift, English, 中文] {...} -- iOS11适配系列教程
486
star
10

WebRTC

WebRTC for iOS
Objective-C
428
star
11

CYLDeallocBlockExecutor

Hello block,byebye dealloc!一行代码代替dealloc完成“self-manager”
Objective-C
253
star
12

CYLSearchViewController

模仿iPhone短信聊天里的搜索框样式,点击搜索后,搜索框平滑移动到导航栏上。
Objective-C
176
star
13

iOS13AdaptationTips

iOS13 AdaptationTips
175
star
14

iOS12AdaptationTips

iOS12AdaptationTips
86
star
15

CYLChatKit

仿微信高度自定义UI、集成第三方IM SDK。An IM App UI Framework, support sending text, pictures, audio, video, location messaging, managing address book, more interesting features.
Objective-C
71
star
16

iOSDevelopmentTips

iOS开发笔记
Objective-C
67
star
17

SMSCodeButton

可用作短信验证码的倒计时 Button
Objective-C
52
star
18

CYLCURLNetworking

Networking based on curl
Objective-C
48
star
19

CYLTabBarControllerDemoForWeib

CYLTabBarController 的示例DEMO
Objective-C
34
star
20

LineLayout

苹果官方展示UICollectionView 用法的 Demo
Objective-C
22
star
21

CYLHttpTest

【调接口神器】可将 XML 或 JSON 数据解析并转换为Plist文件存在本地,方便调接口。
Objective-C
21
star
22

CYLWebViewController

WebViewControllerDemo,可App类似 Safari 的效果,能随着滑动隐藏底部工具栏
Objective-C
20
star
23

CYLTableViewRowAction

Use UITableViewRowAction as if it supports iOS7+.
Objective-C
11
star
24

XcodeMissingTemplates

Add⓵Empty Application.xctemplate ⓶Objective-C category.xctemplate ⓷Objective-C class extension.xctemplate ⓸Objective-C protocol.xctemplate
Objective-C
11
star
25

CYLTabBarController-Swift

Swift版本的CYLTabBarController ( https://github.com/ChenYilong/CYLTabBarController ),支持 CocoaPods 。
11
star
26

CYLBusinessCardButton

重写 UIButton ,使用一个 UIButton,显示一张名片,内含有三个 Label 一个头像。
Objective-C
11
star
27

Flutter101

Flutter101
Dart
8
star
28

CYLSwipeBetweenControllers

手势切换控制器,动画流畅,有过度效果。
Objective-C
8
star
29

HandleViewControlEventsWithBlock

展示如何使用runtime和手势两种方式为UIView添加类似UIButton的addTarget-action-forControlEvents-事件
Objective-C
7
star
30

ChenYilong

2
star
31

ReactNativeDemo

Objective-C++
2
star